meteor-redux | Let 's find | State Container library
kandi X-RAY | meteor-redux Summary
kandi X-RAY | meteor-redux Summary
Meteorux? Reduxor? Let's find out!
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of meteor-redux
meteor-redux Key Features
meteor-redux Examples and Code Snippets
Community Discussions
Trending Discussions on meteor-redux
QUESTION
I am trying to use meteor redux middlewares. Following the tutorials step by step, but have not managed to get it working so far. The problem seems to lie in startSubscription: I can never see the get() and subscribe() functions called, I slipped console calls inside that are empty both in the browser and in the server terminal.
...ANSWER
Answered 2019-Jan-25 at 09:54I finally realized the problem.
First, I had a problem in my store.js file. Specifically, I had deleted by accident the lines related to createReactiveMiddlewares.
const { sources, subscriptions, } = createReactiveMiddlewares(Tracker);
Then, when implementing the actions.js, you have to be really careful about the naming of the actions AND also the Meteor.subscribe method, which has to be named according to the actions. Example bellow, if HOME_POSTS_SUB is equal to "home_randomName", it will not work, because the _SUBSCRIPTION_READY and _SUBSCRIPTION_CHANGED prefixes have to be coherent with the _SUB string value.
export const HOME_POSTS_SUBSCRIPTION_READY = 'HOME_POSTS_SUBSCRIPTION_READY'; export const HOME_POSTS_SUBSCRIPTION_CHANGED = 'HOME_POSTS_SUBSCRIPTION_CHANGED'; export const HOME_POSTS_SUB = 'home.posts'; // will work! //export const HOME_POSTS_SUB = 'home.randomName'; // spoiled!! //export const HOME_POSTS_SUB = 'posts'; // spoiled!!
export const loadHomePosts = () => startSubscription({ key: HOME_POSTS_SUB, subscribe: () => Meteor.subscribe(HOME_POSTS_SUB), get: () => Posts.find().fetch(),
naming HOME_POSTS_... differently will give you a hell lot of troubles later. So, naming the actions correctly has an effect later when you use them in the reducer.js file:
export function home(state = initialState, action) { switch (action.type) { case HOME_POSTS_SUBSCRIPTION_READY: return { ...state, ready: action.payload.ready, postsSubscriptionStopped: false, }; case HOME_POSTS_SUBSCRIPTION_CHANGED: return { ...state, posts: action.payload, }; case STOP_SUBSCRIPTION: return action.payload === HOME_POSTS_SUB ? { ...state, postsSubscriptionStopped: true } : state; default: return state; } }
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install meteor-redux
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page