From 582a1b14846c3bac4b44ea0f964bef922a30d544 Mon Sep 17 00:00:00 2001 From: Nate Hunzaker Date: Thu, 19 Mar 2015 08:31:04 -0400 Subject: [PATCH] [change] Rename Heatbeat.prototype.beat to pump. Expose API for pump to Microcosm --- package.json | 2 +- src/Microcosm.js | 6 +++++- src/__tests__/heartbeat-test.js | 8 ++++---- src/heartbeat.js | 2 +- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index b291fcac..3fa68a1a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "microcosm", - "version": "0.0.2", + "version": "0.1.0", "description": "An experimental flux implimentation", "main": "dist/Microcosm.js", "scripts": { diff --git a/src/Microcosm.js b/src/Microcosm.js index 3c82711b..45f9d1e4 100644 --- a/src/Microcosm.js +++ b/src/Microcosm.js @@ -28,11 +28,15 @@ export default class Microcosm { return this._heart.ignore } + get pump() { + return this._heart.pump + } + _enqueue(payload) { for (let s in this.stores) { this.stores[s].send(payload) } - this._heart.beat() + this._heart.pump() } addActions(actions) { diff --git a/src/__tests__/heartbeat-test.js b/src/__tests__/heartbeat-test.js index 2196a8e3..bd2ee4e5 100644 --- a/src/__tests__/heartbeat-test.js +++ b/src/__tests__/heartbeat-test.js @@ -8,7 +8,7 @@ describe ('Heartbeat', function() { it ('does not flush if there are no callbacks', function() { let spy = sinon.spy(window, 'requestAnimationFrame') - heart.beat() + heart.pump() spy.should.not.have.been.called @@ -17,7 +17,7 @@ describe ('Heartbeat', function() { it ('can listen to callbacks', function(done) { heart.listen(done) - heart.beat() + heart.pump() }) it ('batches subscriptions', function(done) { @@ -26,7 +26,7 @@ describe ('Heartbeat', function() { heart.listen(stub) for (var i = 100; i > 0; i--) { - heart.beat() + heart.pump() } requestAnimationFrame(() => { @@ -40,7 +40,7 @@ describe ('Heartbeat', function() { heart.listen(stub) heart.ignore(stub) - heart.beat() + heart.pump() requestAnimationFrame(() => { stub.should.not.have.been.called diff --git a/src/heartbeat.js b/src/heartbeat.js index 2a1498d6..6f049692 100644 --- a/src/heartbeat.js +++ b/src/heartbeat.js @@ -46,7 +46,7 @@ export default function() { /** * Trigger every callback in the Set */ - beat() { + pump() { if (_callbacks.length > 0) { cancelAnimationFrame(_tick) _tick = requestAnimationFrame(_pump)