-
Notifications
You must be signed in to change notification settings - Fork 14
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
withState hoc #33
base: dev
Are you sure you want to change the base?
withState hoc #33
Conversation
Hmm, I'm not sure about the function names. I'll need to think about this a bit and get back to you. Also, I was thinking that if this library went down this route of specifying what args should be included through higher order functions that it would also do it for other things, like |
Yeah I probably thought so 😄
hmm as for the For the and since our HOC is not only providing the state$, so we need to name it accordingly, I will leave that to you 😄 |
@kanitsharma Well, the idea was to change to just having a single API that everyone uses + using the higher order functions in an ad hoc sort of way to add functionality, where you only import and use them when needed. This would simplify the library in that everyone who uses it would work in basically the same way by default. So, the two APIs would go away and instead we'd just have one API that by default takes in only an action stream. Then, for people who want access to the quick-and-dirty/escape-hatch-y Then, the same thing would be available for the state stream, like what you've shown here. And there could possibly be other useful things as well. For example, we could allow the user to define dependencies upon middleware construction, like what you described above, but instead of ALWAYS injecting those dependencies we just provide access to them through a higher order function, like I'm not sure whether or not this is the best route to go down, but that was the original idea. It has pros and cons. Pros:
Cons:
I'm not 100% sure what the best solution is off the top of my head, but I do think changing the library so that there is only one base API + optional flexibility is a good idea. Finding the right solution will probably require some experimenting with different ideas. |
Another, simpler, option would be to just skip the HOFs altogether and just always pass everything through:
And then the user could use destructuring to pluck off the things they want:
This is definitely the simplest option, but maybe not the best? Not sure. I don't want to remove access to |
I am all up for having different HOFs for different use cases, As I see it would be very exciting to compose the HOFs and make it all pointfree 😄 |
I'm also a fan of pointfree style, but there is a caveat, unfortunately. Pointfree style in TypeScript/Flow can be pretty annoying due to TS/Flow not being able to infer from right to left with BUT, I do think it would be nice to support a pointfree style for those who are willing to annotate or people who are just writing in plain JS. |
Side-note: I would like to rewrite in TypeScript due to getting more into it recently at work, etc. + the library already having TS type definitions, but this would probably also be a good time to add Flow types to the library. I think @most/core already has both TS & Flow types available. |
Agree, but since |
and as far as this is concerned we can use the |
Update on this, |
Here is an example of an epic with withState and mergeState
The inner function in withState is automatically uncurried so we can also it as
Also, lets discuss if you want the function names to be changed