GithubHelp home page GithubHelp logo

Provide a base Store about flux HOT 6 CLOSED

facebook avatar facebook commented on April 26, 2024
Provide a base Store

from flux.

Comments (6)

sterpe avatar sterpe commented on April 26, 2024

Might be using Backbone.event.

Sent from my iPhone

On Nov 12, 2014, at 10:43 PM, Justin Woo [email protected] wrote:

I think it's kind of silly that clients of this module still have to write the same boilerplate for their stores. I think it'd be nice to provide a base for clients.

The simplest way to do this would be to do something like this:

var EventEmitter = require('events').EventEmitter;
var assign = require('react/lib/Object.assign');

var Store = assign({}, EventEmitter.prototype, {
emitChange: function() {
this.emit(CHANGE_EVENT);
},

/**

  • @param {function} callback
    */
    addChangeListener: function(callback) {
    this.on(CHANGE_EVENT, callback);
    },

    /**

  • @param {function} callback
    */
    removeChangeListener: function(callback) {
    this.removeListener(CHANGE_EVENT, callback);
    }
    });

module.exports = Store;
For even better usability, a constructing function could be provided:

function createStore(dispatcherCallback, methods) {
return assign({}, BaseStore, methods, {
dispatcherIndex: Dispatcher.register(dispatcherCallback)
});
}
Here's an 'example' of how I think it could be done/used: https://github.com/kimagure/15-puzzle/blob/master/src/Store.js#L120

Thoughts? Are people's implementations of stores much too different to handle something like this?


Reply to this email directly or view it on GitHub.

from flux.

jedireza avatar jedireza commented on April 26, 2024

I'm happy to share flux-store ❤️

from flux.

fisherwebdev avatar fisherwebdev commented on April 26, 2024

Also see McFly
https://github.com/kenwheeler/mcfly

On Thursday, November 13, 2014, Reza Akhavan [email protected]
wrote:

I'm happy to share flux-store https://github.com/jedireza/flux-store [image:
❤️]


Reply to this email directly or view it on GitHub
#97 (comment).

from flux.

 avatar commented on April 26, 2024

Thank you for reporting this issue and appreciate your patience. We've notified the core team for an update on this issue. We're looking for a response within the next 30 days or the issue may be closed.

from flux.

kyldvs avatar kyldvs commented on April 26, 2024

We just released some of the basic Flux infrastructure we use at Facebook, including a base store.

http://facebook.github.io/flux/docs/flux-utils.html#content

from flux.

justinwoo avatar justinwoo commented on April 26, 2024

cool, thanks! 🍺

from flux.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.