effect icon indicating copy to clipboard operation
effect copied to clipboard

add TSubscriptionRef

Open evelant opened this issue 1 year ago • 3 comments

Type

  • [ ] Refactor
  • [ X] Feature
  • [ ] Bug Fix
  • [ ] Optimization
  • [ ] Documentation Update

Description

Add TSubscriptionRef for STM

Related

  • Related Issue #
  • Closes #

evelant avatar May 10 '24 17:05 evelant

🦋 Changeset detected

Latest commit: 55dcb28e25e473eb172d20d43b817f4c0aa7d7f4

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

This PR includes changesets to release 32 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-libsql 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

changeset-bot[bot] avatar May 10 '24 17:05 changeset-bot[bot]

@mikearnaldi would love to get your feedback on this when you've got a moment. I think it's good to go but this is my first stab at adding a new module and I may have missed things.

evelant avatar May 29 '24 20:05 evelant

removed some comments and debug stuff I accidentally left in internal

evelant avatar Jun 23 '24 14:06 evelant

Cc @tim-smart for a second review, I think I am fine with it albeit have some doubts about mixing stream with stm

mikearnaldi avatar Aug 15 '24 07:08 mikearnaldi

I'm curious what doubts you have about mixing stream and stm? The use case leading me to implement this is when I need the synchronization capabilities of stm but also need the value-over-time for things like rendering UI.

evelant avatar Aug 15 '24 13:08 evelant

I'm curious what doubts you have about mixing stream and stm? The use case leading me to implement this is when I need the synchronization capabilities of stm but also need the value-over-time for things like rendering UI.

Namely subscribing gives you back a non transactional primitive (Stream) I think I'd prefer if subscribing gave you a TDequeue like TPubSub does:

export const subscribe: <A>(self: TPubSub<A>) => STM.STM<TQueue.TDequeue<A>>

mikearnaldi avatar Aug 18 '24 09:08 mikearnaldi

Hmm interesting. I'm not sure what benefit that would offer. I can't think of a use case right now when I'd want a TDequeue instead of a Stream. Did you have something in mind?

evelant avatar Aug 18 '24 13:08 evelant

Hmm interesting. I'm not sure what benefit that would offer. I can't think of a use case right now when I'd want a TDequeue instead of a Stream. Did you have something in mind?

The TQueue interface has all methods returning STM so they can be used transactionally. It's strictly more powerful as you can derive a Stream from a TQueue but not the opposite

mikearnaldi avatar Aug 18 '24 15:08 mikearnaldi

I'll update the PR with the requested changes later this week, thanks for the feedback!

evelant avatar Aug 27 '24 14:08 evelant

@tim-smart I think this is now in a good state, pls have a final review, feel free to merge directly is all looks good

mikearnaldi avatar Oct 08 '24 08:10 mikearnaldi

@mikearnaldi thanks for finishing this up!

evelant avatar Oct 09 '24 12:10 evelant