Comments (7)
I don't think a separate global package is necessary. If this were to be a thing, I think just having the right API in this library would be enough.
from prism.
I kinda like an idea of allowing user to dispatch global actions, it may seem like a hack, but it's not, because redux-elm
works very well with model in form of tree, but doesn't work well with normalized data (which may eventually be handy) so I perceieve this as a bridge between these two approaches.
from prism.
Where are we with this?
I have a case where I have a wrapper App
component which updater
looks something like this:
declare function require(name: string): any;
import { takeEvery } from "redux-saga";
import { take, put, call, fork, select, Effect } from "redux-saga/effects";
import { Map } from "immutable";
const { Updater } = require("redux-elm");
// Initial immutable model/state passed to the Updater.
type Init = () => Map<string, any>;
export const init: Init = () => Map({
isSidebarOpen: false,
isOptionsOpen: false
});
export default new Updater(init())
.case("TOGGLE_SIDEBAR", model => model.set("isSidebarOpen", !model.get("isSidebarOpen")))
.case("TOGGLE_OPTIONS", model => model.set("isOptionsOpen", !model.get("isOptionsOpen")))
.toReducer();
How would I dispatch an action for TOGGLE_SIDEBAR
from within a nested elm component from whereever in my app?
Right now, if I dispatch({type: "TOGGLE_SIDEBAR"})
from a nested elm component UserView
, it actually dispatches UserView.TOGGLE_SIDEBAR
..
Is it possible somehow to solve this?
Is it even possible?
from prism.
@dgsunesen, have you tried using a custom matcher?
http://salsita.github.io/redux-elm/custom-matchers/writing-custom-matcher.html
Using it, for example, you could listen to any event than ends with TOGGLE_SIDEBAR
(however deeply nested in a tree) in a parent/grandparent updater.
I'm not sure if this approach would cover every possible use case, but sometimes you can get away with it.
from prism.
@dvshur - Thanks. I'll let you know if this solves my problem :-)
from prism.
How would one solve this problem in Elm?
Btw. I've found this project while trying to find an answer to my question about reusable components in Redux. I guess you are very qualified to answer it.
from prism.
from prism.
Related Issues (20)
- Don't Call PropTypes HOT 3
- Sibling components interaction best practice HOT 6
- Performance HOT 2
- Request to join cdnjs HOT 1
- Build a umd package for Browser usage
- Reduce bundle size by using rxjs modularity HOT 1
- Mount order and saga registering HOT 8
- Get currentUser state in component Updater HOT 3
- Sagas not getting unmounted HOT 2
- Version 4.x.x HOT 7
- redux-saga update HOT 2
- Documentation links 404 HOT 5
- Where is documentation for v3? HOT 2
- Props 'selector' and 'wrapper' get passed down to enhanced component HOT 3
- prism-redux/escapeRegexp.js is missing a character in the regex
- Questions about using side-effect libraries with prism
- How to wrap/unwrap dynamic components? HOT 2
- Provide a wrapper compatible with the library-provided unwrapper
- EnhanceComponent doesn't work with thunk middleware
- Dynamic list of stateful components HOT 1
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 prism.