From 476caae5ae10e27fc6aa1b004c81c3615fb8f028 Mon Sep 17 00:00:00 2001 From: Maurice de Beijer Date: Sat, 17 Oct 2015 16:40:05 +0200 Subject: [PATCH] Added test --- reflux/reflux-tests.ts | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 reflux/reflux-tests.ts diff --git a/reflux/reflux-tests.ts b/reflux/reflux-tests.ts new file mode 100644 index 000000000..ce4a2920c --- /dev/null +++ b/reflux/reflux-tests.ts @@ -0,0 +1,39 @@ +/// + + +var Reflux: RefluxCore; + +var syncActions = Reflux.createActions([ + "statusUpdate", + "statusEdited", + "statusAdded" +]); + + +var asyncActions = Reflux.createActions({ + fireBall: {asyncResult: true} +}); + +asyncActions.fireBall.listen(function () { + // Trigger async action + setTimeout(() => this.completed(true), 1000); +}); + + +// Creates a DataStore +var statusStore = Reflux.createStore({ + + // Initial setup + init: function () { + + // Register statusUpdate action + this.listenTo(asyncActions.fireBall, this.onFireBall); + }, + // Callback + onFireBall: function (flag) { + var status = flag ? 'ONLINE' : 'OFFLINE'; + + // Pass on to listeners + this.trigger(status); + } +});