ff-stream-web

git clone git://archive.git.mtrnord.blog/MTRNord/ff-stream-web.git
Log | Files | Refs | README | LICENSE

commit 3d6a7e2bec3df72b7d8e269618e529baeaee90d3
parent 800b8388c0090e889263d53c8c4f3c3b5383508c
Author: Konstantin Tarkus <hello@tarkus.me>
Date:   Thu, 13 Nov 2014 20:28:36 +0300

Add comments into the Store.js

Diffstat:
Msrc/core/Store.js | 19+++++++++++++++++--
Msrc/layouts/DefaultLayout.js | 2+-
2 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/src/core/Store.js b/src/core/Store.js @@ -14,19 +14,34 @@ var invariant = require('react/lib/invariant'); var CHANGE_EVENT = 'change'; +/** + * The Flux store base class. + */ class Store { + /** + * Constructs a Store object, extends it with EventEmitter and supplied + * methods parameter, and creates a mixin property for use in components. + * + * @param {object} methods Public methods for Store instance. + * @constructor + */ constructor(methods) { var self = this; invariant(!methods.dispatcherToken,'"dispatcherToken" is a reserved name and cannot be used as a method name.'); - invariant(!methods.mixin,'"mixin" is a reserved name and cannot be used as a method name.'); + invariant(!methods.Mixin,'"Mixin" is a reserved name and cannot be used as a method name.'); assign(this, EventEmitter.prototype, methods); this.dispatcherToken = null; - this.mixin = { + + /** + * Base functionality for every Store constructor. Mixed into the + * `Store` prototype, but exposed statically for easy access. + */ + this.Mixin = { componentDidMount: function() { self.addChangeListener(this.onChange); diff --git a/src/layouts/DefaultLayout.js b/src/layouts/DefaultLayout.js @@ -25,7 +25,7 @@ function getState() { var DefaultLayout = React.createClass({ - mixins: [PageStore.mixin], + mixins: [PageStore.Mixin], getInitialState() { return getState();