Comments (13)
If we implement an array notation for the signals as I saw at one point you @christianalfoni were tossing about then we can just concat ourselves rather than adding more API.
const $actionGroup = [
action1,
action2,
[action3]
];
controller.signal('somethingHappened', [ someAction, anotherAction ].concat($actionGroup));
from cerebral.
Haha, that is just brilliant :D
from cerebral.
I will keep this open until it is documented ;-)
from cerebral.
that reminds me that we should support having an array at "top level" too. So:
controller.signal('somethingHappened', someAction, anotherAction);
// is the same as
controller.signal('somethingHappened', [ someAction, anotherAction ]);
from cerebral.
Another feature ticket perhaps :)
from cerebral.
Changed this issue instead... though, hm, I think we have to require the top level to be an array. Because:
controller.signal('somethingHappened', [asyncAction]);
controller.signal('somethingHappened', [syncAction].concat(otherActions));
They are not compatible... so yeah, that will break the API. But again, a quick fix and easy to throw error on it.
Cause it have to be:
controller.signal('somethingHappened', [ [asyncAction] ]);
controller.signal('somethingHappened', [syncAction].concat(otherActions));
from cerebral.
I see what you mean. Hmm, could start to look messy. I wonder if other people have suggestions...
from cerebral.
Yeah, lets keep it open and await more feedback. But signals are most commonly typed like this:
controller.signal('somethingHappened', [
[asyncAction]
]);
controller.signal('somethingHappened', [
syncAction
].concat(otherActions));
So it is not that bad ;-)
from cerebral.
Ahh yes, the new line provides the visual separation :)
from cerebral.
If top level actions must be provided as an array then why not accept multiple arrays without the need for concat()
?
controller.signal('somethingHappened', [
[asyncAction]
], otherActionsArray);
controller.signal('somethingHappened', [
syncAction
], otherActionsArray);
Just need to enforce that all arguments must be arrays.
from cerebral.
Jup, that I was also thinking about that. In that scenario it makes sense just to add it as a second argument, but:
controller.signal('somethingHappened', [
[asyncAction, {
[SUCCESS]: [mySpecialAction].concat(otherSuccessActions)
}]
], otherActionsArray);
So yeah, lets change to multiple arrays instead of multiple functions as arguments to the signal?
from cerebral.
Can we use the ES6 spread operator for this perhaps?
const otherActions = [
action,
otherAction
];
controller.signal('somethingHappened', [firstAction, ...otherActions] );
Example above:
controller.signal('somethingHappened', [
[asyncAction, {
[SUCCESS]: [mySpecialAction, ...otherSuccessActions]
}],
...otherActionsArray ]);
Second example: http://odetocode.com/blogs/scott/archive/2014/09/02/features-of-es6-part-5-the-spread.aspx
from cerebral.
Of course we can, haha, I have not got this new syntax into my intuition system yet ;-)
So we do not need top level array at all, you can use spread for arguments too
controller.signal('somethingHappened', controller.signal('somethingHappened',
firstAction,
...otherActions
);
Let me update the other issue with this, and close this one. #46
from cerebral.
Related Issues (20)
- Allow providers to have keys other than functions HOT 1
- What happened to mobx-state-tree HOT 4
- Change in computed state does not trigger reactions HOT 2
- A certain combination of feature usage causes forceUpdate() on an unmounted component HOT 1
- How to use cerebral in vue-router hooks? HOT 2
- reaction errors HOT 7
- module.signals is DEPRECATED but controller in @cerebral/mobx-state-tree can't provide sequences HOT 1
- Can't resolve nested value via moduleState HOT 2
- Docs test page spelling error HOT 2
- When using devtools, cannot change store state using string path. HOT 1
- codesandbox.io using wrong cerebral version. HOT 1
- Setting non-existent path in state works without devtools, throws error with devtools HOT 1
- Cerebral v4: Deprecated React lifecycle methods HOT 1
- function-tree Can't resolve './StopExecution' HOT 3
- Can't resolve nested value via moduleState (from computed) HOT 1
- Cerebral 5.2.0: inferno does render child before parent HOT 2
- access dotted keys HOT 1
- parallel does not work as expected HOT 1
- `addModule` doesn't initialize reactions
- React 19 compatibility
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 cerebral.