Building Backbone apps using Flux

ref: image from flux Github page github.com/facebook/flux

This is what I want:

var MyView = Backbone.View.extend({
...
onActionClicked: function() {
...
this.model.set({value: changedValue}); // Throw exception
...
}
...
});
var MyModel = FluxBackbone.Model.extend({
...
dispatchCallback: function(action) {
var data = action.data;
this.set(data); // Do not throw exception
...
}
});

The solution:

var Dispatcher = require(‘flux’).Dispatcher;
var FluxBackbone = require('flux-backbone');
var AppDispatcher = new Dispatch();var model = new FluxBackbone.Model({}, {
dispatcher: AppDispatcher
});
/* --- or --
model.setDispatcher(AppDispatcher);
*/

 by the author.

--

--

--

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Victor Doss

Victor Doss

More from Medium

LAB: Active Directory Setup using Oracle VirtualBox | Adding Users with PowerShell

How to connect Next.js with an external API and perform CRUD operations.

Tutorial: IBM Cloud Pak single sign-on (SSO) integration with Ping Identity and Microsoft Active…

How to install google benchmark in EC2-Environment