-
Notifications
You must be signed in to change notification settings - Fork 15
Description
3.0 was released last November and I’m itching to do some breaking changes. Here’s what I’m planning:
-
Move the combinator functions to their own module.EDIT: I’m starting to think the static methods should stay on the class, even if we implement the other combinator functions.
I initially wrote combinators as static methods (Repeater.race) on the exported Repeater class, both on the assumption that they would be commonly used and because it draws a nice parallel withPromise.race. If repeaters ever end up becoming a standard thing, this might be how the functions are defined, but as a library, having the combinator functions exposed as static methods messes with the bundle size, and is not tree-shakeable. Additionally, it’s been brought to my attention (Not that great for implementing transducers? #48) that unlike my previous assumption, there actually may be a need for repeaters in the implementation of combinators likemapandfilterand creating a module for these functions all defined in one place would be nice. I’ve checked out some other combinator libraries and it seems like many of them leak memory and cause deadlocks, so there is going to be value in creating a combinator module, especially for combinators likeswitchMap, which require a high degree of concurrency. -
Kill the monorepo. Package monorepos are annoying to deal with. I have made the mistake of not updating the internal versions of packages multiple times, there’s duplicated tooling across the packages, and I hate having to navigate a multi-level directory structure for what are essentially single-file modules. My plan is to get all the modules exported under the main repeater package and deprecate the other packages.
-
Kill pubsub. I’m probably the only one using the pubsub module right now, but after a year of async iterator usage, what I believe is that you should always start with an EventTarget or callback-based abstraction when writing custom classes. Async iterators are high-level, always async abstractions and we shouldn’t encourage people to write abstractions which exclusively use them.
-
Rename some functions. One thing I’m noticing is that the function names in
limitersandtimersare squatting on the expected name for the actual repeater object (const ??? = timeout(1000)). Most of the time you inline the function call directly in thefor awaitstatement, but for cases where you need to assign the repeater to a variable the naming can be kind of annoying. I’d like to maybe adopt some kind of consistent naming pattern likecreateTimeout,genTimeoutor maybesourceTimeout. -
Stop repeaters when the executor settles.EDIT: April 2021 I think this one also might not be worth it. I’m reading through code which uses Repeaters in the wild, and it might be a pain in the butt to have to fix all that code. This change strikes me as being less explicit and more confusing. (Should the Repeater automatically stop when its executor fulfills? #49) Related to implementing combinators, I want to implicitly stop repeaters when the executor function returns. Whenever I write combinators I consistently feel compelled to writestopcalls directly before the return statement or in a finally block. This is probably one of the more disruptive breaking changes as it will cause repeaters to stop unexpectedly if you didn’t await anything in the executor, but you can reconstruct the old behavior by awaiting or returning thestoppromise. If your repeater executor exits synchronously, I encourage you to somehow await or return the stop promise to prepare for this change.