Comments (16)
@skellock The primary virtue of the FSA is that it's a spec people can rally around, and write all kinds of utilities for. Creators, middlewares, reducers... all can assume the shape of the action object. Without that ability to make assumptions about where the type is, where the payload is, etc., you can't have a shared ecosystem of utilities.
In your case, for instance, you're making an implicit assumption that's similar: that everyone will have a prop on their actions called 'type'. That's enough for the limited scope you're focused on.
But what if I also want to write middlewares based on payload, like Thunks or Sagas do? Well, then I need to know more about the rest of the shape.
FSA gives us all that. And, it lets different utilities with different concerns all interoperate transparently. Without it, the tools available get much flatter, and less capable.
from reduxsauce.
@skellock I can pick that, but I'd prefer a sort of:
const { Types, Creators } = createActions({
...
},
{ createFactory: someActionCreator } // activate FSA behavior here (or make it default?)
)
Rather then {fsa: true}
. Then, developer can improve that with:
import { createAction } from 'redux-actions';
const createFsaAction = (config) =>
createActions(
config,
{ createFactory: createAction }
)
Will you give green light to that, or you'd like {fsa: true}
?
from reduxsauce.
I think it would be good to considerate redux-actions as an engine for FSA creation. So probably instead of:
const { Types, Creators } = createActions({
...
},
{ useFca: true } // activate FSA behavior here (or make it default?)
)
Developer should install that lib, and code should look like:
const { Types, Creators } = createActions({
...
},
{ createFactory: createAction } // activate FSA behavior here (or make it default?)
)
So I think what the lib should support is configurable action creators, and can remain FSA agnostic.
from reduxsauce.
Any update on this? I want to use https://github.com/diegohaz/redux-saga-thunk and looks like I cannot use createActions() as I can't add meta field to actions.
from reduxsauce.
To be honest, I never quite got FSA. I tried it on early project and it was just an extra level of data. Truthfully, I don't really see it around that much, but perhaps I'm not looking at the right projects.
Now, having said that...
What you're proposing seems very reasonable.
Two issues I see:
- How do we determine a failure goes into the
error
property? - For meta-based properties, how do we determine it's actually meta? When the arity of the call is 1 more than the expected inputs?
I wonder if perhaps we just make a createFsaActions()
so we can drop that optional object at the end? That might feel a bit better for FSA-folk?
from reduxsauce.
Using createFSAActions()
sounds good. My view on your issues:
- My proposal did indeed not follow the "Errors as a first class" concept, and implies using *_FAILURE actions. For my purposes it's fine, but I'm not proficient to assess the importance of this aspect. There seem to be some hybrid forms out there. Alternatively, we could go node-style, and "reserve" the first parameter for potential errors:
myAction(error_or_null, ...inputs )
. But that's quite cumbersome for my taste. - Yes, that was my thought.
from reduxsauce.
Ya, I'm on board after @xml's awesome explanation.
How about { fsa: true }
?
createActions({ ...stuffOfLegends }, { fsa: true })
This would be fine for attaching payloads, but what about meta
and/or error
?
Aren't we kinda getting to the point where it's easier to not use an action creator at all? I don't use FSA, so I really don't know.
from reduxsauce.
Did we have any progress on this? I want to use react-native-offline and would love to keep using reduxsauce, but it requires the actions to be in this format:
const action = {
type: 'FETCH_USER_ID',
payload: {
id: 2
},
meta: {
retry: true
}
};
from reduxsauce.
No updates from my end. I don't use FSA... if you're looking to contribute tho, that'd be awesome.
from reduxsauce.
Thanks @vaukalak !!!!
It will be great to stick with reduxsauce if you manage to develop this. I really love the library!
from reduxsauce.
Iβd very much welcome fsa support.
I like the idea of having createFsaActions
baked in as an additional export. If we can prevent the interface of the current creatActions
from changing that would be awesome. I really donβt even mind if the whole internals change to support this!
from reduxsauce.
@fredbt I'm in the exact same case as you with react-native-offline.
Have you found a way to pass meta
params with reduxsauce?
from reduxsauce.
Not yet @jmeiss ... I'm still waiting for the solution by Mr. @vaukalak :)
from reduxsauce.
Hello @matttti ! Did you have any progress in the implementation of the FSA for reduxsauce? (not being picky, just asking ... I know it's open source and not your job in the end :)
Thank you so much!
from reduxsauce.
Still no solution for that ????
from reduxsauce.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
from reduxsauce.
Related Issues (20)
- createReducer with Typescript HOT 29
- How to handle extra logic using reduxsauce approach ? HOT 4
- Immutable is missing HOT 2
- How i can make code more clean with reduxsauce-typescript-immutable HOT 12
- The state is not updated HOT 2
- Multiple files uploading HOT 2
- typescript options prefix HOT 5
- Publish reduxsauce HOT 4
- How to use this with useDispatch (react-redux) HOT 1
- Documentation on how to use resettableReducer HOT 7
- I can not get 100% tests coverage HOT 2
- The reason you are no longer using it? HOT 3
- Reduxsauce cannot dispatch action HOT 2
- Reusable reducers HOT 6
- state.merge is not a function HOT 7
- repo createActions example error TypeScript HOT 2
- confused to use createTypes or createActions HOT 2
- how to use Creators or Types with intelligency for IDE HOT 7
- Action type does not support object as showed in the docs HOT 6
- minor enhancement to allow empty argument to actionCreator with defaults HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from reduxsauce.