-
Notifications
You must be signed in to change notification settings - Fork 142
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
Minimal cross-framework standard #4
Comments
Or limit scope to Redux, so that it doesn't get too generic. Probably most middleware wouldn't work with other frameworks anyway. |
@taion Every dispatched Flux action is part of a asynchronous sequence. Think of every other kind of asynchronous sequence — observables, streams, promises, etc. *All * of them have the concept of being in a "error" state.
Yes, you're right that current Flux libraries often use separate types to implement error handling — they can continue doing that while still conforming to FSA, simply by omitting Here's an exercise: look at the source of redux-promise and tell me how you would implement it with multiple action types. https://github.com/acdlite/redux-promise/blob/master/src/index.js#L15-L20 If the word "success" is too confusing, we can rename it to "next" using the Observable parlance. Perhaps that would be clearer. A |
@clearjs There's no reason why a spec that works for Redux shouldn't also work for all Flux implementations. Even middleware isn't Redux-specific. All middleware does is wrap a |
I don't think In my view, the benefit of putting Hence what I have outlined - type and payload are the bare minimum for dispatching and handling actions, and a minimal standard should aim to be agnostic toward anything else. Implementation-wise, success/failure status seems like a special case of "metadata meaningful to EDIT: Fixed phrasing above |
@taion What value would such generic standard provide? Which kinds of tools could be built on it? |
Also, while I can parse this on a technical level, in plain English this makes no sense if I'm dispatching a
But mostly my point is that I look at |
It gives you a way to dispatch actions from one framework that another framework can use. And standardizing all information other than the |
Metadata can be defined as every field except payload, no need to nest it IMO. |
Not currently, but it should! Good standards encourage good ideas. Making failed actions (actions that represents errors) a first-class concept is important, for the reasons described in my comment above. Suggestions for alternatives are totally welcome, but omitting it completely is not an option. I'm thinking we should replace |
@acdlite A boolean is one option. An error object (e.g., exception) is another. In the latter case, payload could contain user-friendly error message. |
Usually you start with the ideas, not with the standards... If Isn't success/error status literally metadata here? |
One thing I might very well want to do is have a |
This isn't some idea I pulled out of my ass yesterday. Flummox has been using it successfully for months, and it's worked really well. If you give me a specific reason why treating errors as a first class concept is a bad idea besides "other libraries don't do this" I will take that into consideration. |
@taion |
I think But they'd be used in a very similar way, e.g. with something like a promise-based middleware that dispatched I think the sheer fact that we can't agree over how a status field ought to be used is prima facie evidence that it's not an obvious fit for the standard. I just think it's better to go from the perspective of adoption driving a standard than the standard attempting to drive adoption - otherwise if people find something better, you're just left with cruft in the standard you have to deprecate. But in any case it's not a "minimal, common standard" if you have a carve-out for something that only Flummox does, regardless of the inherent merit of the feature. |
@taion Yes, it is special. Since it is necessary, it is a required metadata field, not optional. |
@taion I simply disagree. If something's a good idea, we shouldn't leave it out of the spec just because it's not yet popular. |
Bringing over the latest comments from #8 {
// any: Symbol, string, number, object, function. A unique way to identify the action dispatched
type: ActionTypes.ADD_TODO,
// any: whatever is being dispatched
payload: { text: 'Create FSA Proposal' },
// information about the action itself
meta: {
// string | number: a unique identifier for the dispatch
id: 'abcdef123',
// string representation of the particular action type
// since Symbols are not strings and action type can be anything, having a way to identify an
// action as a string is useful for serializing, debugging, and logging.
displayType: 'ActionTypes.ADD_TODO'
}
} I don't like the name displayType, other than that I think this is the most minimal interoperable action we can standardize on. Regarding the debate on here about |
Unique identifier for a dispatch seems to be very useful, thus moving it out of Allowing the As for the Also,
|
I agree an optional unique identifier would be useful, especially for something like #7. I can see some value in it being a top level field (less typing, avoids needing to check if
|
I remain in disagreement over But I've said my piece about this repeatedly. There's no definition of "minimal" with which I am familiar that includes:
Goodness-of-idea is an orthogonal concept to minimalism. My understanding of the term calls for preferring to not including things that are not strictly necessary, regardless of merit as a good idea or not. I like the idea of having specific pre-defined keys under |
Can you please explain why you don't like On Sun, Jul 5, 2015 at 5:23 PM, Jimmy Jia [email protected]
|
I think its not being necessary is a big part of why it should not be included. Like with Maybe this gets to the heart of the disagreement? In your own words, this is supposed to be "a minimal, common standard" - if I'm not arguing that |
I see where you're coming from. My problem with putting it in So how do you like that approach — the core spec is just On Sun, Jul 5, 2015 at 5:34 PM, Jimmy Jia [email protected]
|
I like that a lot. And I like the idea of formal extensions putting things outside of |
Spec versioning (actually, extensibility) was the only compelling reason for me to make Error handling seems to belong to the core of spec, since probably every real-world use of actions assumes error handling. Without it, the only spec value is to allow extensions, I guess. Or am I missing something? Also, without it each user would need to define their own way to handle errors (or select among popular ones), thus diminishing possibility to reuse any middleware that depends on error handling. When we're talking about action interoperability, I believe this actually means ability to reuse various kinds of code for processing actions: creating them with minimal boilerplate, creating them in a way that solves certain commonly occurring problems, transforming them (e.g., filtering, mapping, reducing). Even if the only thing this spec enables is to create such reusable libraries, then it is worth the effort. Arguments over merits of particular spec aspects should appeal to specific examples of code that wouldn't work or would work worse than with alternative approaches. Spec should probably focus more on explaining the goals and value of itself, with examples or references to working code. A series of libraries that @acdlite is creating along with this spec shows its usability (such libraries wouldn't be applicable in projects that follow different action schemas). |
Like I said, I don't care too much about whether well-defined extensions go into Even without error handling, just by defining exactly what Of course a lot of great things can be done with extensions, but I think that's exactly why extensibility is so important. Time travel, optimistic updates, &c. - these are all super cool things that we want the ability to do in a consistent way so that we don't end up needlessly reinventing them over and over again. |
Can we close this out with a resolution? I'd like to implement FSA for next alt release. My current thoughts:
|
Well, I'm not using Flux any more, and really the concerns here are probably not that relevant any more. Redux is Redux, Alt is hanging around because Alt is cool, and Reflux remains vaguely undead. I don't think there's anything further productive to accomplish here. |
Continuation of our discussion from Reactiflux -
I like what you're trying to do here, but I think what you have maps more closely to what you've built in Flummox than you intend, and doesn't do a good job of describing how other Flux frameworks behave, which limits its utility as a potential interop standard and makes the name not as descriptive as it could be.
For example, you specifically privilege
status
, while it's not at all standard for Flux frameworks to have a concept of action status as separate from the action itself - neither Alt nor Marty have specific concepts of success/failure actions and just have those treated as actions with different constants.As I see it, there are really 3 types of data on an action -
I'd probably organize the spec rather like:
I'd specify:
type
: Something potentially appropriate as an object key, either a name string, a mangled name/ID string, or an ES6 Symbol - this should be sufficient to uniquely set up handlersmetadata
: Framework-specific values not generated directly by the user - these can be things like original name of the action (in case it was mangled to dedupe), semantic action status for frameworks that explicitly model this (again, most frameworks do not), or other logging/diagnostic flags, or things useful for middlewarepayload
: As close as possible to what the user directly specifiedI can see where you're going with specifying
status
as a special thing, but for my tastes, it's too opinionated. I understand that you feel that it makes sense to Flux frameworks to have semantic notions of action status, and I can see the arguments you've made in that regard, but it's not suitable to insert this as part of what aims to be a "minimal, common standard" when other frameworks often do not express or capture that notion in this way - and moreover when there exists a more generic abstraction (i.e. themetadata
) that can capture similar framework peculiar things in a way that makes it clear where the potential interop barriers sit.The text was updated successfully, but these errors were encountered: