apeman-react-mixins
Version:
React mixin set of apeman.
49 lines (37 loc) • 828 B
JSX
/**
* Mixin for history.
* @mixin ApHistoryMixin
*/
import React, {PropTypes as types} from 'react'
import apHistory from 'apeman-brws-history'
import defaults from 'defaults'
/** @lends ApHistoryMixin */
let ApHistoryMixin = {
// --------------------
// Custom
// --------------------
$apHistoryMixed: true,
// --------------------
// Specs
// --------------------
// --------------------
// Lifecycle
// --------------------
componentWillMount () {
const s = this
let noop = () => undefined
defaults(s, {
historyDidPop: noop
})
},
componentDidMount () {
const s = this
apHistory.onPop(s.historyDidPop)
},
componentWillUnmount () {
const s = this
apHistory.offPop(s.historyDidPop)
}
}
export default Object.freeze(ApHistoryMixin)