Giter Club home page Giter Club logo

Comments (16)

xml avatar xml commented on June 10, 2024 7

@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.

vaukalak avatar vaukalak commented on June 10, 2024 2

@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.

vaukalak avatar vaukalak commented on June 10, 2024 1

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.

vedmant avatar vedmant commented on June 10, 2024 1

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.

skellock avatar skellock commented on June 10, 2024

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:

  1. How do we determine a failure goes into the error property?
  2. 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.

matttti avatar matttti commented on June 10, 2024

Using createFSAActions() sounds good. My view on your issues:

  1. 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.
  2. Yes, that was my thought.

from reduxsauce.

skellock avatar skellock commented on June 10, 2024

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.

fredbt avatar fredbt commented on June 10, 2024

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.

skellock avatar skellock commented on June 10, 2024

No updates from my end. I don't use FSA... if you're looking to contribute tho, that'd be awesome.

from reduxsauce.

fredbt avatar fredbt commented on June 10, 2024

Thanks @vaukalak !!!!

It will be great to stick with reduxsauce if you manage to develop this. I really love the library!

from reduxsauce.

skellock avatar skellock commented on June 10, 2024

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.

jmeiss avatar jmeiss commented on June 10, 2024

@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.

fredbt avatar fredbt commented on June 10, 2024

Not yet @jmeiss ... I'm still waiting for the solution by Mr. @vaukalak :)

from reduxsauce.

fredbt avatar fredbt commented on June 10, 2024

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.

mustafamagdy avatar mustafamagdy commented on June 10, 2024

Still no solution for that ????

from reduxsauce.

stale avatar stale commented on June 10, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.