Exploring Effects and Struggling with Streams: A Journey from rxjs to fp-ts
Hey, I'm currently looking into effects, which looks really awesome. I'm coming from rxjs and dabbled a bit with fp-ts. I guess wrapping promises is the easier part, but now I'm trying to grasp Streams (in combination with Scopes, making it extra hard, which both are not yet documented, which is probably why I'm struggling).
I've watched the youtube tutorial for the parcel file watcher (https://www.youtube.com/watch?v=8B6YAax5Tes) which helped me a bit. I only later found the repo with the example which probably could be linked in the video description (https://github.com/Effect-Community/file-watcher/blob/feat/file-system-subscription/packages/file-watcher/src/index.ts).
I've created a gist where I'm trying to migrate the code to the new API using a scope. It works, but I'm wondering if this is the most idiomatic approach.
https://gist.github.com/DomiR/955b3d24a8dba260725b03f2b8c0e0cf
1. Now I'm struggeling to understand how trigger the finalizer. Could someone provide an example for subscribing to an endless stream and unsubscribing after some elements or a condition is met?
2. My understanding of Streams is currently, that I can runDrain, which would produce a fiber (like a subscription in rxjs) and I should be able to interrupt the fiber (like unsubscribe in rxjs?). Is this assumption correct?
3. In rxjs the take operator will unsubscribe from the source observable automatically, which I'm not seeing in Effect, do they behave differently? (Could be of course that my finalizer is not set up correctly)
Thank you for all the hard work you are putting into this project
I've watched the youtube tutorial for the parcel file watcher (https://www.youtube.com/watch?v=8B6YAax5Tes) which helped me a bit. I only later found the repo with the example which probably could be linked in the video description (https://github.com/Effect-Community/file-watcher/blob/feat/file-system-subscription/packages/file-watcher/src/index.ts).
I've created a gist where I'm trying to migrate the code to the new API using a scope. It works, but I'm wondering if this is the most idiomatic approach.
https://gist.github.com/DomiR/955b3d24a8dba260725b03f2b8c0e0cf
1. Now I'm struggeling to understand how trigger the finalizer. Could someone provide an example for subscribing to an endless stream and unsubscribing after some elements or a condition is met?
2. My understanding of Streams is currently, that I can runDrain, which would produce a fiber (like a subscription in rxjs) and I should be able to interrupt the fiber (like unsubscribe in rxjs?). Is this assumption correct?
3. In rxjs the take operator will unsubscribe from the source observable automatically, which I'm not seeing in Effect, do they behave differently? (Could be of course that my finalizer is not set up correctly)
Thank you for all the hard work you are putting into this project
