Ladislav M
Ladislav M

Reputation: 2187

Reflux callback after store is changed

I'm working on Chrome Extension using React.js and Reflux. Now I need to notify all parts of extension about changes when store is updated with one callback.

Something like:

function(newStore){
  chrome.runtime.sendMessage({action: 'updateStore', store: newStore});
}

Where is the point in Reflux for adding such callback?

Upvotes: 1

Views: 518

Answers (1)

Bill D
Bill D

Reputation: 111

I haven't built a chrome extension using Reflux but in general the pattern is to call:

store.listen(function(data) {
    // data is whatever your store invoked by saying this.trigger(...)
});

The callback function will be invoked whenever your store calls trigger with new data.

Upvotes: 4

Related Questions