Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Stream): add Stream.onStart api #3302

Merged
merged 3 commits into from
Jul 18, 2024

Conversation

dilame
Copy link
Contributor

@dilame dilame commented Jul 18, 2024

Not sure about name, maybe it should be tapSubscribe?

Type

  • Refactor
  • Feature
  • Bug Fix
  • Optimization
  • Documentation Update

Implement Stream.tapStart that adds an effect to be executed at the start of the stream.

import { Console, Effect, Stream } from "effect";

const stream = Stream.make(1, 2, 3).pipe(
  Stream.tapStart(Console.log("Stream started")),
  Stream.map((n) => n * 2),
  Stream.tap((n) => Console.log(`after mapping: ${n}`))
) 

Effect. runPromise(Stream. runCollect(stream)).then(console. log) 
// Stream started 
// after mapping: 2 
// after mapping: 4 
// after mapping: 6 
// { _id: 'Chunk', values: [ 2, 4, 6 ] }

Copy link

changeset-bot bot commented Jul 18, 2024

🦋 Changeset detected

Latest commit: 79e501d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 31 packages
Name Type
effect Minor
@effect/cli Major
@effect/cluster-browser Major
@effect/cluster-node Major
@effect/cluster-workflow Major
@effect/cluster Major
@effect/experimental Major
@effect/opentelemetry Major
@effect/platform-browser Major
@effect/platform-bun Major
@effect/platform-node-shared Major
@effect/platform-node Major
@effect/platform Major
@effect/printer-ansi Major
@effect/printer Major
@effect/rpc-http Major
@effect/rpc Major
@effect/schema Major
@effect/sql-d1 Major
@effect/sql-drizzle Major
@effect/sql-kysely Major
@effect/sql-mssql Major
@effect/sql-mysql2 Major
@effect/sql-pg Major
@effect/sql-sqlite-bun Major
@effect/sql-sqlite-node Major
@effect/sql-sqlite-react-native Major
@effect/sql-sqlite-wasm Major
@effect/sql Major
@effect/typeclass Major
@effect/vitest Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot changed the base branch from main to next-minor July 18, 2024 21:16
packages/effect/src/internal/stream.ts Outdated Show resolved Hide resolved
packages/effect/src/internal/stream.ts Outdated Show resolved Hide resolved
dilame and others added 2 commits July 19, 2024 00:45
@dilame
Copy link
Contributor Author

dilame commented Jul 18, 2024

Done. What do you think about Stream.onEnd with concat(self, drain(fromEffect(effect)))?

@tim-smart
Copy link
Member

Done. What do you think about Stream.onEnd with concat(self, drain(fromEffect(effect)))?

I'm OK with it. Feel free to open a seperate PR.

@tim-smart tim-smart changed the title feat(Stream): tapStart feat(Stream): add Stream.onStart api Jul 18, 2024
@tim-smart tim-smart merged commit c33c9b0 into Effect-TS:next-minor Jul 18, 2024
9 checks passed
@github-actions github-actions bot mentioned this pull request Jul 18, 2024
github-actions bot pushed a commit that referenced this pull request Jul 20, 2024
Co-authored-by: Tim <hello@timsmart.co>
github-actions bot pushed a commit that referenced this pull request Jul 20, 2024
Co-authored-by: Tim <hello@timsmart.co>
github-actions bot pushed a commit that referenced this pull request Jul 21, 2024
Co-authored-by: Tim <hello@timsmart.co>
github-actions bot pushed a commit that referenced this pull request Jul 21, 2024
Co-authored-by: Tim <hello@timsmart.co>
github-actions bot pushed a commit that referenced this pull request Jul 22, 2024
Co-authored-by: Tim <hello@timsmart.co>
github-actions bot pushed a commit that referenced this pull request Jul 22, 2024
Co-authored-by: Tim <hello@timsmart.co>
github-actions bot pushed a commit that referenced this pull request Jul 22, 2024
Co-authored-by: Tim <hello@timsmart.co>
github-actions bot pushed a commit that referenced this pull request Jul 23, 2024
Co-authored-by: Tim <hello@timsmart.co>
github-actions bot pushed a commit that referenced this pull request Jul 23, 2024
Co-authored-by: Tim <hello@timsmart.co>
github-actions bot pushed a commit that referenced this pull request Jul 23, 2024
Co-authored-by: Tim <hello@timsmart.co>
github-actions bot pushed a commit that referenced this pull request Jul 23, 2024
Co-authored-by: Tim <hello@timsmart.co>
github-actions bot pushed a commit that referenced this pull request Jul 23, 2024
Co-authored-by: Tim <hello@timsmart.co>
github-actions bot pushed a commit that referenced this pull request Jul 23, 2024
Co-authored-by: Tim <hello@timsmart.co>
github-actions bot pushed a commit that referenced this pull request Jul 23, 2024
Co-authored-by: Tim <hello@timsmart.co>
github-actions bot pushed a commit that referenced this pull request Jul 25, 2024
Co-authored-by: Tim <hello@timsmart.co>
github-actions bot pushed a commit that referenced this pull request Jul 25, 2024
Co-authored-by: Tim <hello@timsmart.co>
github-actions bot pushed a commit that referenced this pull request Jul 25, 2024
Co-authored-by: Tim <hello@timsmart.co>
github-actions bot pushed a commit that referenced this pull request Jul 25, 2024
Co-authored-by: Tim <hello@timsmart.co>
github-actions bot pushed a commit that referenced this pull request Jul 25, 2024
Co-authored-by: Tim <hello@timsmart.co>
github-actions bot pushed a commit that referenced this pull request Jul 26, 2024
Co-authored-by: Tim <hello@timsmart.co>
github-actions bot pushed a commit that referenced this pull request Jul 26, 2024
Co-authored-by: Tim <hello@timsmart.co>
github-actions bot pushed a commit that referenced this pull request Jul 26, 2024
Co-authored-by: Tim <hello@timsmart.co>
github-actions bot pushed a commit that referenced this pull request Jul 26, 2024
Co-authored-by: Tim <hello@timsmart.co>
github-actions bot pushed a commit that referenced this pull request Jul 26, 2024
Co-authored-by: Tim <hello@timsmart.co>
github-actions bot pushed a commit that referenced this pull request Jul 26, 2024
Co-authored-by: Tim <hello@timsmart.co>
github-actions bot pushed a commit that referenced this pull request Jul 26, 2024
Co-authored-by: Tim <hello@timsmart.co>
github-actions bot pushed a commit that referenced this pull request Jul 26, 2024
Co-authored-by: Tim <hello@timsmart.co>
github-actions bot pushed a commit that referenced this pull request Jul 26, 2024
Co-authored-by: Tim <hello@timsmart.co>
github-actions bot pushed a commit that referenced this pull request Jul 26, 2024
Co-authored-by: Tim <hello@timsmart.co>
github-actions bot pushed a commit that referenced this pull request Jul 27, 2024
Co-authored-by: Tim <hello@timsmart.co>
github-actions bot pushed a commit that referenced this pull request Jul 28, 2024
Co-authored-by: Tim <hello@timsmart.co>
github-actions bot pushed a commit that referenced this pull request Jul 28, 2024
Co-authored-by: Tim <hello@timsmart.co>
github-actions bot pushed a commit that referenced this pull request Jul 28, 2024
Co-authored-by: Tim <hello@timsmart.co>
github-actions bot pushed a commit that referenced this pull request Jul 29, 2024
Co-authored-by: Tim <hello@timsmart.co>
github-actions bot pushed a commit that referenced this pull request Jul 29, 2024
Co-authored-by: Tim <hello@timsmart.co>
github-actions bot pushed a commit that referenced this pull request Jul 29, 2024
Co-authored-by: Tim <hello@timsmart.co>
github-actions bot pushed a commit that referenced this pull request Jul 29, 2024
Co-authored-by: Tim <hello@timsmart.co>
tim-smart added a commit that referenced this pull request Jul 29, 2024
Co-authored-by: Tim <hello@timsmart.co>
github-actions bot pushed a commit that referenced this pull request Jul 29, 2024
Co-authored-by: Tim <hello@timsmart.co>
github-actions bot pushed a commit that referenced this pull request Jul 30, 2024
Co-authored-by: Tim <hello@timsmart.co>
github-actions bot pushed a commit that referenced this pull request Jul 30, 2024
Co-authored-by: Tim <hello@timsmart.co>
tim-smart added a commit that referenced this pull request Jul 30, 2024
Co-authored-by: Tim <hello@timsmart.co>
@github-actions github-actions bot mentioned this pull request Jul 30, 2024
tim-smart added a commit that referenced this pull request Jul 30, 2024
Co-authored-by: Tim <hello@timsmart.co>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants