Skip to content

Commit

Permalink
Remove deprecation warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
goatslacker committed Apr 25, 2015
1 parent 118b2fa commit a76e048
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 46 deletions.
15 changes: 0 additions & 15 deletions src/alt/AltStore.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import EventEmitter from 'eventemitter3'
import assign from 'object-assign'
import Symbol from 'es-symbol'
import { deprecatedBeforeAfterEachWarning } from './utils/warnings'
import * as Sym from './symbols/symbols'

const {
Expand Down Expand Up @@ -37,13 +36,6 @@ export default class AltStore {
this.dispatchToken = alt.dispatcher.register((payload) => {
if (model[LIFECYCLE].beforeEach) {
model[LIFECYCLE].beforeEach(payload, this[STATE_CONTAINER])
} else if (typeof model.beforeEach === 'function') {
deprecatedBeforeAfterEachWarning()
model.beforeEach(
payload.action.toString(),
payload.data,
this[STATE_CONTAINER]
)
}

if (model[LISTENERS][payload.action]) {
Expand All @@ -66,13 +58,6 @@ export default class AltStore {

if (model[LIFECYCLE].afterEach) {
model[LIFECYCLE].afterEach(payload, this[STATE_CONTAINER])
} else if (typeof model.afterEach === 'function') {
deprecatedBeforeAfterEachWarning()
model.afterEach(
payload.action.toString(),
payload.data,
this[STATE_CONTAINER]
)
}
})

Expand Down
7 changes: 0 additions & 7 deletions src/alt/utils/warnings.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,3 @@ export function warn(msg) {
console.warn(new ReferenceError(msg))
}
}

export function deprecatedBeforeAfterEachWarning() {
warn(
'beforeEach/afterEach functions on the store are deprecated ' +
'use beforeEach/afterEach as a lifecycle method instead'
)
}
26 changes: 2 additions & 24 deletions test/before-and-after-test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Alt from '../dist/alt-with-runtime'
import Alt from '../'
import { assert } from 'chai'

import sinon from 'sinon'

const alt = new Alt()
Expand Down Expand Up @@ -85,28 +86,5 @@ export default {
assert.ok(beforeValue === 1, 'before has current state')
assert.ok(afterValue === 2, 'after has next state')
},

'deprecated warning'() {
console.warn = sinon.spy()

class Foo {
constructor() {
this.bindListeners({
change: action.fire
})
}
beforeEach() { }
afterEach() { }
change() { }
}

assert(console.warn.callCount === 0)

alt.createStore(Foo)

action.fire()

assert.ok(console.warn.calledTwice)
}
}
}

0 comments on commit a76e048

Please sign in to comment.