camelot-unchained
Version:
Camelot Unchained Client Library
53 lines (52 loc) • 2 kB
JavaScript
/**
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
;
var Reflux = require('reflux');
var events_1 = require('../../events');
var AnnouncementsStore = {
create: function create() {
var actions = Reflux.createActions(['start', 'stop']);
var store = Reflux.createStore({
topic: events_1.default.clientEventTopics.handlesAnnouncements,
listenables: actions,
init: function init() {
// Initialise the store is basic info. This is so that React components
// can use the Store to initialise their state in getDefaultState().
this.info = {
message: "",
type: -1
};
},
start: function start() {
console.log('in AnnouncementStore:start()');
var store = this;
// If this store has already been started, then ingore subsequent start
// request
if (this.started) return;
this.started = true;
// Listen to the event group for this unit frame
events_1.default.on(this.topic, function (announcement) {
// Update store info
store.info = {
message: announcement.message,
type: announcement.type
};
// Trigger changed notification for this store
store.trigger(store.info);
});
},
stop: function stop() {
// TODO
}
});
return {
store: store,
actions: actions
};
}
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = AnnouncementsStore;