PubSubJS | Dependency free publish/subscribe for JavaScript | Runtime Evironment library
kandi X-RAY | PubSubJS Summary
kandi X-RAY | PubSubJS Summary
PubSubJS is a topic-based publish/subscribe library written in JavaScript. PubSubJS has synchronisation decoupling, so topics are published asynchronously. This helps keep your program predictable as the originator of topics will not be blocked while consumers process them. For the adventurous, PubSubJS also supports synchronous topic publication. This can give a speedup in some environments (browsers, not all), but can also lead to some very difficult to reason about programs, where one topic triggers publication of another topic in the same execution chain. PubSubJS is designed to be used within a single process, and is not a good candidate for multi-process applications (like Node.js – Cluster with many sub-processes). If your Node.js app is a single process app, you're good. If it is (or is going to be) a multi-process app, you're probably better off using redis Pub/Sub or similar.
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 PubSubJS
PubSubJS Key Features
PubSubJS Examples and Code Snippets
Community Discussions
Trending Discussions on PubSubJS
QUESTION
I have a React app using Redux to handle the overall state of the app that also integrates some legacy Javascript library to present a specific viewer (on a canvas). The legacy library manages for the viewer its own state (and I don't have access to it). I now have the case that one of my components need to trigger an event on the viewer in another component (e.g. reset the viewer using the legacy library).
I can think of two solutions:
- Do a Redux state change (e.g.
{reset: true}
) that is provided to the viewer component via props. And after the viewer component reseted the viewer, it directly resets the state itself (e.g. `{reset: false}). - Bypass Redux and use some kind of PubSub pattern for those components to communicate directly to each other without any Redux state change.
Is there recommended way? What are the advantages/disadvantages? One downside of option 1 seems that it triggers a re-render when the state is updated the second time ({reset: false}
).
ANSWER
Answered 2018-Feb-11 at 13:14Another way i have come up is by specifying the time at which it got reset. If the time changes this will trigger a re-render.
on dispatch(reset())
Action:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install PubSubJS
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