pelotom / unionize

Boilerplate-free functional sum types in TypeScript
MIT License
402 stars 14 forks source link

Compatibility with Flux Standard Actions (multiple top-level value/payload keys) #45

Closed joshburgess closed 6 years ago

joshburgess commented 6 years ago

While testing the viability of using unionize for actions & reducers in an existing Redux app, I discovered that, despite being able to alias tag as type and value as payload, to provide a bit of Redux-compatibility, there is no real way to handle being able to add error and meta keys on the same level as payload.

You could, of course, lump those keys under your value/payload property and then use some extra mapping step to extract those things out & create an FSA style action object, but that takes away from a lot of the convenience & nicety of using a solution like unionize.

Is there anyway around this?

Somewhat unrelated, but I'm also curious about the viability of approaching a library like this that doesn't rely on records but instead allows the type constructors for each member of the union to accept multiple arguments. I'm thinking along the lines of something like the way daggy works, but typed with TS. Any thoughts on this? Any caveats that would make it very difficult/not possible?

pelotom commented 6 years ago

Could you maybe sketch out how you'd like to be able to configure this?

joshburgess commented 6 years ago

I actually don't really have any sort of solution off the top of my head. I would need to familiarize myself with how the library works and think about it a bit, I think.

joshburgess commented 6 years ago

Closing this because I misunderstood something about the library and this issue is not relevant anymore.