Skip to content

Commit

Permalink
[change] Rename Heatbeat.prototype.beat to pump. Expose API for pump …
Browse files Browse the repository at this point in the history
…to Microcosm
  • Loading branch information
nhunzaker committed Mar 19, 2015
1 parent 43c8135 commit 582a1b1
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "microcosm",
"version": "0.0.2",
"version": "0.1.0",
"description": "An experimental flux implimentation",
"main": "dist/Microcosm.js",
"scripts": {
Expand Down
6 changes: 5 additions & 1 deletion src/Microcosm.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
8 changes: 4 additions & 4 deletions src/__tests__/heartbeat-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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) {
Expand All @@ -26,7 +26,7 @@ describe ('Heartbeat', function() {
heart.listen(stub)

for (var i = 100; i > 0; i--) {
heart.beat()
heart.pump()
}

requestAnimationFrame(() => {
Expand All @@ -40,7 +40,7 @@ describe ('Heartbeat', function() {

heart.listen(stub)
heart.ignore(stub)
heart.beat()
heart.pump()

requestAnimationFrame(() => {
stub.should.not.have.been.called
Expand Down
2 changes: 1 addition & 1 deletion src/heartbeat.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export default function() {
/**
* Trigger every callback in the Set
*/
beat() {
pump() {
if (_callbacks.length > 0) {
cancelAnimationFrame(_tick)
_tick = requestAnimationFrame(_pump)
Expand Down

0 comments on commit 582a1b1

Please sign in to comment.