Future API changes
See original GitHub issuecontinuing the discussion from https://github.com/emmanueltouzery/prelude.ts/pull/8
@qm3ster => all good points, food for thought. Note that prelude.ts has a Stream
collection type and yes it works as you described. I would consider renaming the on* methods and have them possibly returning void instead of returning the Future, but I’m not sure for the name right now (maybe onFailed=>ifFail, onSucceeded=>ifSuccess, onCompleted=>match or matchValue), or even if that’s really the good path forward.
That’s also connected to some changes I’m working on in these methods regarding error handling.
And besides that I think yes probably map & flatMap should be lazy, and we can also add an explicit. .trigger() (with in apidoc that you don’t need it if you do await, or if you do X or Y and so on). The trigger would likely return void.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:16 (9 by maintainers)
Top GitHub Comments
I started working on a PR in which I would remove laziness and also take into account feedback on the current API from @qm3ster (who had other comments besides the laziness/eagerness), and also add the do-like constructor. I didn’t strongly decide to remove laziness, but I figure also in other areas prelude.ts tried to keep things simple and working in the way people expect them to be.
I’ll submit this through a PR so that people can comment on the changes. I’m still open for feedback on the laziness/eagerness aspect! Implementation simplicity is also a (lesser) concern.
clearly my worry is that someone forgets to call
trigger
. I’m thinking about adding some constructorFuture.run
, or renamingFuture.of
toFuture.run
. But I must think it through.