diff --git a/package.json b/package.json index 2b2a9dd..ba630e4 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,9 @@ "react": "15.3.2", "react-dom": "15.3.2" }, + "eslintConfig": { + "extends": "react-app" + }, "scripts": { "start": "react-scripts start", "build": "react-scripts build", diff --git a/src/controller/CounterCommand.js b/src/controller/CounterCommand.js index 75c9f26..5e65107 100644 --- a/src/controller/CounterCommand.js +++ b/src/controller/CounterCommand.js @@ -13,6 +13,8 @@ export default class CounterCommand extends SimpleCommand { case EventNames.SUBVIEW_LOCAL_COUNT: counter = this.facade.getProxy(CounterProxy.NAME_LOCAL); break; + default: + break; } if (counter) { diff --git a/src/core/constants/NotificationNames.js b/src/core/constants/NotificationNames.js index 168dd9f..2bb9b06 100644 --- a/src/core/constants/NotificationNames.js +++ b/src/core/constants/NotificationNames.js @@ -3,7 +3,7 @@ const NotificationNames = { DATA_CHANGE: 'DATA_CHANGE', RENDER: 'RENDER', STARTUP: 'STARTUP', - STARTUP_COMPLETE: 'STARTUP_COMPLETE' + STARTUP_COMPLETE: 'STARTUP_COMPLETE', }; export default NotificationNames; diff --git a/src/core/controller/DataChangeCommand.js b/src/core/controller/DataChangeCommand.js index 00b72d8..b1c31b9 100644 --- a/src/core/controller/DataChangeCommand.js +++ b/src/core/controller/DataChangeCommand.js @@ -8,7 +8,7 @@ export default class DataChangeCommand extends SimpleCommand { localState[note.getType()] = data; const state = this.facade.getState(); - if(Object.hasOwnProperty.call(state, note.getType())){ + if (Object.hasOwnProperty.call(state, note.getType())) { this.facade.updateState(localState); } } diff --git a/src/core/controller/StartupCommand.js b/src/core/controller/StartupCommand.js index a0f4ea9..162cd5d 100644 --- a/src/core/controller/StartupCommand.js +++ b/src/core/controller/StartupCommand.js @@ -4,16 +4,16 @@ import { ModelPrepCommand, ViewPrepCommand } from '../../controller/prep-command export default class StartupCommand extends MacroCommand { - initializeMacroCommand() { - this.addSubCommand(ModelPrepCommand); - this.addSubCommand(ViewPrepCommand); - } + initializeMacroCommand() { + this.addSubCommand(ModelPrepCommand); + this.addSubCommand(ViewPrepCommand); + } - execute(note) { + execute(note) { // console.log('StartupCommand execute()'); - super.execute(note); - this.facade.removeCommand(NotificationNames.STARTUP); - this.facade.send(NotificationNames.RENDER); - } + super.execute(note); + this.facade.removeCommand(NotificationNames.STARTUP); + this.facade.send(NotificationNames.RENDER); + } } diff --git a/src/core/controller/StateChangeCommand.js b/src/core/controller/StateChangeCommand.js index 07f7a50..4cb51dd 100644 --- a/src/core/controller/StateChangeCommand.js +++ b/src/core/controller/StateChangeCommand.js @@ -1,5 +1,4 @@ import { SimpleCommand } from 'pmvc'; -import NotificationNames from '../constants/NotificationNames'; export default class StateChangeCommand extends SimpleCommand { execute(note) { diff --git a/src/core/utils/shallowEqual.js b/src/core/utils/shallowEqual.js index 76df378..f82be71 100644 --- a/src/core/utils/shallowEqual.js +++ b/src/core/utils/shallowEqual.js @@ -1,23 +1,23 @@ export default function shallowEqual(objA, objB) { if (objA === objB) { - return true + return true; } - const keysA = Object.keys(objA) - const keysB = Object.keys(objB) + const keysA = Object.keys(objA); + const keysB = Object.keys(objB); if (keysA.length !== keysB.length) { - return false + return false; } // Test for A's keys different from B. - const hasOwn = Object.prototype.hasOwnProperty + const hasOwn = Object.prototype.hasOwnProperty; for (let i = 0; i < keysA.length; i++) { if (!hasOwn.call(objB, keysA[i]) || objA[keysA[i]] !== objB[keysA[i]]) { - return false + return false; } } - return true + return true; } diff --git a/src/core/utils/storeShape.js b/src/core/utils/storeShape.js index 16b1b14..a808446 100644 --- a/src/core/utils/storeShape.js +++ b/src/core/utils/storeShape.js @@ -1,7 +1,7 @@ -import { PropTypes } from 'react' +import { PropTypes } from 'react'; export default PropTypes.shape({ subscribe: PropTypes.func.isRequired, dispatch: PropTypes.func.isRequired, - getState: PropTypes.func.isRequired -}) + getState: PropTypes.func.isRequired, +}); diff --git a/src/core/utils/warning.js b/src/core/utils/warning.js index 0fdfb02..cda848a 100644 --- a/src/core/utils/warning.js +++ b/src/core/utils/warning.js @@ -7,14 +7,14 @@ export default function warning(message) { /* eslint-disable no-console */ if (typeof console !== 'undefined' && typeof console.error === 'function') { - console.error(message) + console.error(message); } /* eslint-enable no-console */ try { // This error was thrown as a convenience so that if you enable // "break on all exceptions" in your console, // it would pause the execution at this line. - throw new Error(message) + throw new Error(message); /* eslint-disable no-empty */ } catch (e) {} /* eslint-enable no-empty */ diff --git a/src/core/utils/wrapActionCreators.js b/src/core/utils/wrapActionCreators.js index 3032a94..5bcb308 100644 --- a/src/core/utils/wrapActionCreators.js +++ b/src/core/utils/wrapActionCreators.js @@ -1,6 +1,6 @@ // import { bindActionCreators } from 'redux' -export default function wrapActionCreators(actionCreators){ +export default function wrapActionCreators(actionCreators) { console.log('wrapActionCreators', actionCreators); // return dispatch => bindActionCreators(actionCreators, dispatch) } diff --git a/src/core/view/PMVCMediator.js b/src/core/view/PMVCMediator.js index 81a7dba..6fed902 100644 --- a/src/core/view/PMVCMediator.js +++ b/src/core/view/PMVCMediator.js @@ -9,7 +9,7 @@ export default class PMVCMediator extends Mediator { constructor(name, view) { if(!name){ - instanceCount = instanceCount+1; + instanceCount += 1; name = PMVCMediator.NAME+ '_'+instanceCount; } super(name, view); diff --git a/src/core/view/Provider.js b/src/core/view/Provider.js index fcb9a5b..ddf5579 100644 --- a/src/core/view/Provider.js +++ b/src/core/view/Provider.js @@ -1,6 +1,5 @@ import React, { Component } from 'react'; import storeShape from '../utils/storeShape' -import assign from 'object-assign'; export default class Provider extends Component { diff --git a/src/core/view/connect.js b/src/core/view/connect.js index 72e88d7..e72d667 100644 --- a/src/core/view/connect.js +++ b/src/core/view/connect.js @@ -1,198 +1,197 @@ -import { Component, createElement } from 'react' -import storeShape from '../utils/storeShape' -import shallowEqual from '../utils/shallowEqual' -import wrapActionCreators from '../utils/wrapActionCreators' -import warning from '../utils/warning' -import isPlainObject from 'lodash/isPlainObject' -import hoistStatics from 'hoist-non-react-statics' -import invariant from 'invariant' - -const defaultMapStateToProps = state => ({}) // eslint-disable-line no-unused-vars -const defaultMapDispatchToProps = dispatch => ({ dispatch }) +import { Component, createElement } from 'react'; +import storeShape from '../utils/storeShape'; +import shallowEqual from '../utils/shallowEqual'; +import wrapActionCreators from '../utils/wrapActionCreators'; +import warning from '../utils/warning'; +import isPlainObject from 'lodash/isPlainObject'; +import hoistStatics from 'hoist-non-react-statics'; +import invariant from 'invariant'; + +const defaultMapStateToProps = state => ({}); // eslint-disable-line no-unused-vars +const defaultMapDispatchToProps = dispatch => ({ dispatch }); const defaultMergeProps = (stateProps, dispatchProps, parentProps) => ({ ...parentProps, ...stateProps, - ...dispatchProps -}) + ...dispatchProps, +}); function getDisplayName(WrappedComponent) { - return WrappedComponent.displayName || WrappedComponent.name || 'Component' + return WrappedComponent.displayName || WrappedComponent.name || 'Component'; } -let errorObject = { value: null } +const errorObject = { value: null }; function tryCatch(fn, ctx) { try { - return fn.apply(ctx) + return fn.apply(ctx); } catch (e) { - errorObject.value = e - return errorObject + errorObject.value = e; + return errorObject; } } // Helps track hot reloading. -let nextVersion = 0 +let nextVersion = 0; -export default function connect(mapStateToProps, MediatorClass, mapDispatchToProps, mergeProps, options = {withRef: true }) { - const shouldSubscribe = Boolean(mapStateToProps) - const mapState = mapStateToProps || defaultMapStateToProps +export default function connect(mapStateToProps, MediatorClass, mapDispatchToProps, mergeProps, options = { withRef: true }) { + const shouldSubscribe = Boolean(mapStateToProps); + const mapState = mapStateToProps || defaultMapStateToProps; - let mapDispatch + let mapDispatch; if (typeof mapDispatchToProps === 'function') { - mapDispatch = mapDispatchToProps + mapDispatch = mapDispatchToProps; } else if (!mapDispatchToProps) { - mapDispatch = defaultMapDispatchToProps + mapDispatch = defaultMapDispatchToProps; } else { - mapDispatch = wrapActionCreators(mapDispatchToProps) + mapDispatch = wrapActionCreators(mapDispatchToProps); } - const finalMergeProps = mergeProps || defaultMergeProps - const { pure = true, withRef = false } = options - const checkMergedEquals = pure && finalMergeProps !== defaultMergeProps + const finalMergeProps = mergeProps || defaultMergeProps; + const { pure = true, withRef = false } = options; + const checkMergedEquals = pure && finalMergeProps !== defaultMergeProps; // Helps track hot reloading. - const version = nextVersion++ + const version = nextVersion++; return function wrapWithConnect(WrappedComponent) { - const connectDisplayName = `Connect(${getDisplayName(WrappedComponent)})` + const connectDisplayName = `Connect(${getDisplayName(WrappedComponent)})`; function checkStateShape(props, methodName) { if (!isPlainObject(props)) { warning( `${methodName}() in ${connectDisplayName} must return a plain object. ` + `Instead received ${props}.` - ) + ); } } function computeMergedProps(stateProps, dispatchProps, parentProps) { - const mergedProps = finalMergeProps(stateProps, dispatchProps, parentProps) + const mergedProps = finalMergeProps(stateProps, dispatchProps, parentProps); if (process.env.NODE_ENV !== 'production') { - checkStateShape(mergedProps, 'mergeProps') + checkStateShape(mergedProps, 'mergeProps'); } - return mergedProps + return mergedProps; } class Connect extends Component { - shouldComponentUpdate() { - return !pure || this.haveOwnPropsChanged || this.hasStoreStateChanged + return !pure || this.haveOwnPropsChanged || this.hasStoreStateChanged; } constructor(props, context) { - super(props, context) + super(props, context); this.version = version; this.type = 'connect'; this.store = props.store || context.store; this.mediator = null; invariant(this.store, - `Could not find "store" in either the context or ` + + 'Could not find "store" in either the context or ' + `props of "${connectDisplayName}". ` + - `Either wrap the root component in a , ` + + 'Either wrap the root component in a , ' + `or explicitly pass "store" as a prop to "${connectDisplayName}".` - ) + ); - const storeState = this.store.getState() - this.state = { storeState } + const storeState = this.store.getState(); + this.state = { storeState }; this.clearCache(); } computeStateProps(store, props) { if (!this.finalMapStateToProps) { - return this.configureFinalMapState(store, props) + return this.configureFinalMapState(store, props); } - const state = store.getState() + const state = store.getState(); const stateProps = this.doStatePropsDependOnOwnProps ? this.finalMapStateToProps(state, props) : - this.finalMapStateToProps(state) + this.finalMapStateToProps(state); if (process.env.NODE_ENV !== 'production') { - checkStateShape(stateProps, 'mapStateToProps') + checkStateShape(stateProps, 'mapStateToProps'); } - return stateProps + return stateProps; } configureFinalMapState(store, props) { - const mappedState = mapState(store.getState(), props) - const isFactory = typeof mappedState === 'function' + const mappedState = mapState(store.getState(), props); + const isFactory = typeof mappedState === 'function'; - this.finalMapStateToProps = isFactory ? mappedState : mapState - this.doStatePropsDependOnOwnProps = this.finalMapStateToProps.length !== 1 + this.finalMapStateToProps = isFactory ? mappedState : mapState; + this.doStatePropsDependOnOwnProps = this.finalMapStateToProps.length !== 1; if (isFactory) { - return this.computeStateProps(store, props) + return this.computeStateProps(store, props); } if (process.env.NODE_ENV !== 'production') { - checkStateShape(mappedState, 'mapStateToProps') + checkStateShape(mappedState, 'mapStateToProps'); } - return mappedState + return mappedState; } computeDispatchProps(store, props) { if (!this.finalMapDispatchToProps) { - return this.configureFinalMapDispatch(store, props) + return this.configureFinalMapDispatch(store, props); } - const { dispatch } = store + const { dispatch } = store; const dispatchProps = this.doDispatchPropsDependOnOwnProps ? this.finalMapDispatchToProps(dispatch, props) : - this.finalMapDispatchToProps(dispatch) + this.finalMapDispatchToProps(dispatch); if (process.env.NODE_ENV !== 'production') { - checkStateShape(dispatchProps, 'mapDispatchToProps') + checkStateShape(dispatchProps, 'mapDispatchToProps'); } - return dispatchProps + return dispatchProps; } configureFinalMapDispatch(store, props) { - const mappedDispatch = mapDispatch(store.dispatch, props) - const isFactory = typeof mappedDispatch === 'function' + const mappedDispatch = mapDispatch(store.dispatch, props); + const isFactory = typeof mappedDispatch === 'function'; - this.finalMapDispatchToProps = isFactory ? mappedDispatch : mapDispatch - this.doDispatchPropsDependOnOwnProps = this.finalMapDispatchToProps.length !== 1 + this.finalMapDispatchToProps = isFactory ? mappedDispatch : mapDispatch; + this.doDispatchPropsDependOnOwnProps = this.finalMapDispatchToProps.length !== 1; if (isFactory) { - return this.computeDispatchProps(store, props) + return this.computeDispatchProps(store, props); } if (process.env.NODE_ENV !== 'production') { - checkStateShape(mappedDispatch, 'mapDispatchToProps') + checkStateShape(mappedDispatch, 'mapDispatchToProps'); } - return mappedDispatch + return mappedDispatch; } updateStatePropsIfNeeded() { - const nextStateProps = this.computeStateProps(this.store, this.props) + const nextStateProps = this.computeStateProps(this.store, this.props); if (this.stateProps && shallowEqual(nextStateProps, this.stateProps)) { - return false + return false; } - this.stateProps = nextStateProps - return true + this.stateProps = nextStateProps; + return true; } updateDispatchPropsIfNeeded() { - const nextDispatchProps = this.computeDispatchProps(this.store, this.props) + const nextDispatchProps = this.computeDispatchProps(this.store, this.props); if (this.dispatchProps && shallowEqual(nextDispatchProps, this.dispatchProps)) { - return false + return false; } - this.dispatchProps = nextDispatchProps - return true + this.dispatchProps = nextDispatchProps; + return true; } updateMergedPropsIfNeeded() { - const nextMergedProps = computeMergedProps(this.stateProps, this.dispatchProps, this.props) + const nextMergedProps = computeMergedProps(this.stateProps, this.dispatchProps, this.props); if (this.mergedProps && checkMergedEquals && shallowEqual(nextMergedProps, this.mergedProps)) { - return false + return false; } - this.mergedProps = nextMergedProps - return true + this.mergedProps = nextMergedProps; + return true; } isSubscribed() { @@ -209,7 +208,7 @@ export default function connect(mapStateToProps, MediatorClass, mapDispatchToPro tryUnsubscribe() { if (this.mediator) { this.store.unsubscribe(this); - this.mediator = null + this.mediator = null; } } @@ -218,74 +217,74 @@ export default function connect(mapStateToProps, MediatorClass, mapDispatchToPro // } componentDidMount() { - this.trySubscribe() + this.trySubscribe(); } componentWillReceiveProps(nextProps) { if (!pure || !shallowEqual(nextProps, this.props)) { - this.haveOwnPropsChanged = true + this.haveOwnPropsChanged = true; } } componentWillUnmount() { - this.tryUnsubscribe() - this.clearCache() + this.tryUnsubscribe(); + this.clearCache(); } clearCache() { - this.dispatchProps = null - this.stateProps = null - this.mergedProps = null - this.haveOwnPropsChanged = true - this.hasStoreStateChanged = true - this.haveStatePropsBeenPrecalculated = false - this.statePropsPrecalculationError = null - this.renderedElement = null - this.finalMapDispatchToProps = null - this.finalMapStateToProps = null + this.dispatchProps = null; + this.stateProps = null; + this.mergedProps = null; + this.haveOwnPropsChanged = true; + this.hasStoreStateChanged = true; + this.haveStatePropsBeenPrecalculated = false; + this.statePropsPrecalculationError = null; + this.renderedElement = null; + this.finalMapDispatchToProps = null; + this.finalMapStateToProps = null; } - setViewState(state, cb){ + setViewState(state, cb) { const el = this.getWrappedInstance(); - if(el){ + if (el) { el.setState(state, cb); } } handleChange() { if (!this.mediator) { - return + return; } - const storeState = this.store.getState() - const prevStoreState = this.state.storeState + const storeState = this.store.getState(); + const prevStoreState = this.state.storeState; if (pure && prevStoreState === storeState) { - return + return; } if (pure && !this.doStatePropsDependOnOwnProps) { - const haveStatePropsChanged = tryCatch(this.updateStatePropsIfNeeded, this) + const haveStatePropsChanged = tryCatch(this.updateStatePropsIfNeeded, this); if (!haveStatePropsChanged) { - return + return; } if (haveStatePropsChanged === errorObject) { - this.statePropsPrecalculationError = errorObject.value + this.statePropsPrecalculationError = errorObject.value; } - this.haveStatePropsBeenPrecalculated = true + this.haveStatePropsBeenPrecalculated = true; } - this.hasStoreStateChanged = true - this.setState({ storeState }) + this.hasStoreStateChanged = true; + this.setState({ storeState }); } getWrappedInstance() { invariant(withRef, - `To access the wrapped instance, you need to specify ` + - `{ withRef: true } as the fourth argument of the connect() call.` - ) + 'To access the wrapped instance, you need to specify ' + + '{ withRef: true } as the fourth argument of the connect() call.' + ); - return this.refs.wrappedInstance + return this.refs.wrappedInstance; } render() { @@ -294,92 +293,91 @@ export default function connect(mapStateToProps, MediatorClass, mapDispatchToPro hasStoreStateChanged, haveStatePropsBeenPrecalculated, statePropsPrecalculationError, - renderedElement - } = this + renderedElement, + } = this; - this.haveOwnPropsChanged = false - this.hasStoreStateChanged = false - this.haveStatePropsBeenPrecalculated = false - this.statePropsPrecalculationError = null + this.haveOwnPropsChanged = false; + this.hasStoreStateChanged = false; + this.haveStatePropsBeenPrecalculated = false; + this.statePropsPrecalculationError = null; if (statePropsPrecalculationError) { - throw statePropsPrecalculationError + throw statePropsPrecalculationError; } - let shouldUpdateStateProps = true - let shouldUpdateDispatchProps = true + let shouldUpdateStateProps = true; + let shouldUpdateDispatchProps = true; if (pure && renderedElement) { shouldUpdateStateProps = hasStoreStateChanged || ( haveOwnPropsChanged && this.doStatePropsDependOnOwnProps - ) + ); shouldUpdateDispatchProps = - haveOwnPropsChanged && this.doDispatchPropsDependOnOwnProps + haveOwnPropsChanged && this.doDispatchPropsDependOnOwnProps; } - let haveStatePropsChanged = false - let haveDispatchPropsChanged = false + let haveStatePropsChanged = false; + let haveDispatchPropsChanged = false; if (haveStatePropsBeenPrecalculated) { - haveStatePropsChanged = true + haveStatePropsChanged = true; } else if (shouldUpdateStateProps) { - haveStatePropsChanged = this.updateStatePropsIfNeeded() + haveStatePropsChanged = this.updateStatePropsIfNeeded(); } if (shouldUpdateDispatchProps) { - haveDispatchPropsChanged = this.updateDispatchPropsIfNeeded() + haveDispatchPropsChanged = this.updateDispatchPropsIfNeeded(); } - let haveMergedPropsChanged = true + let haveMergedPropsChanged = true; if ( haveStatePropsChanged || haveDispatchPropsChanged || haveOwnPropsChanged ) { - haveMergedPropsChanged = this.updateMergedPropsIfNeeded() + haveMergedPropsChanged = this.updateMergedPropsIfNeeded(); } else { - haveMergedPropsChanged = false + haveMergedPropsChanged = false; } if (!haveMergedPropsChanged && renderedElement) { - return renderedElement + return renderedElement; } if (withRef) { this.renderedElement = createElement(WrappedComponent, { ...this.mergedProps, - ref: 'wrappedInstance' - }) + ref: 'wrappedInstance', + }); } else { this.renderedElement = createElement(WrappedComponent, this.mergedProps - ) + ); } - return this.renderedElement + return this.renderedElement; } } - Connect.displayName = connectDisplayName - Connect.WrappedComponent = WrappedComponent + Connect.displayName = connectDisplayName; + Connect.WrappedComponent = WrappedComponent; Connect.contextTypes = { - store: storeShape - } + store: storeShape, + }; Connect.propTypes = { - store: storeShape - } + store: storeShape, + }; if (process.env.NODE_ENV !== 'production') { Connect.prototype.componentWillUpdate = function componentWillUpdate() { - if (this.version === version) { - return + return; } // We are hot reloading! - this.version = version - this.trySubscribe() - this.clearCache() - } + this.version = version; + this.trySubscribe(); + this.clearCache(); + }; } - return hoistStatics(Connect, WrappedComponent) - } + return hoistStatics(Connect, WrappedComponent); + }; } diff --git a/src/core/view/connectMediator.js b/src/core/view/connectMediator.js index e341b75..6038cf6 100644 --- a/src/core/view/connectMediator.js +++ b/src/core/view/connectMediator.js @@ -1,39 +1,37 @@ import PMVCMediator from './PMVCMediator'; -import assign from 'object-assign'; import { applyDecorators, decorate, autobind, mixin } from 'core-decorators'; const mediatorDecorators = { handleNotification(func) { - return notification => { + return (notification) => { PMVCMediator.prototype.handleNotification.call(this, notification); func.call(this, notification); - } + }; }, listNotificationInterests(func) { - return ()=> PMVCMediator.prototype.listNotificationInterests.call(this).concat(func.call(this)); + return () => PMVCMediator.prototype.listNotificationInterests.call(this).concat(func.call(this)); }, onRegister(func) { return () => { func.call(this); - PMVCMediator.prototype.onRegister.call(this) - } + PMVCMediator.prototype.onRegister.call(this); + }; }, onRemove(func) { return () => { func.call(this); - PMVCMediator.prototype.onRemove.call(this) - } + PMVCMediator.prototype.onRemove.call(this); + }; }, -} +}; const connectMediator = (TargetClass) => { - const { prototype } = TargetClass; const propsToInherit = ['handleNotification', 'listNotificationInterests', 'onRegister', 'onRemove']; const propsToDecorate = []; @@ -57,7 +55,7 @@ const connectMediator = (TargetClass) => { for (let i = 0, l = propsToInherit.length; i < l; i++) { const b = propsToInherit[i]; - if(propsToDecorate.indexOf(b) === -1){ + if (propsToDecorate.indexOf(b) === -1) { TargetClass.prototype[b] = PMVCMediator.prototype[b]; } } @@ -65,6 +63,6 @@ const connectMediator = (TargetClass) => { mixin(PMVCMediator.prototype)(TargetClass); return TargetClass; -} +}; export default connectMediator; diff --git a/src/view/App.js b/src/view/App.js index 5de8a22..de1796a 100644 --- a/src/view/App.js +++ b/src/view/App.js @@ -12,7 +12,7 @@ class App extends Component { }; render() { - const {appInfo, counterGlobal} = this.props; + const {appInfo} = this.props; return (
diff --git a/src/view/SubviewMediator.js b/src/view/SubviewMediator.js index 519762d..b35fc7d 100644 --- a/src/view/SubviewMediator.js +++ b/src/view/SubviewMediator.js @@ -1,7 +1,5 @@ import { Mediator } from 'pmvc'; -import { NotificationNames, EventNames } from '../constants/AppConstants'; -import CounterProxy from '../model/CounterProxy'; -import CounterCommand from '../controller/CounterCommand'; +import { EventNames } from '../constants/AppConstants'; export default class SubViewMediator extends Mediator { @@ -11,25 +9,17 @@ export default class SubViewMediator extends Mediator { return [EventNames.SUBVIEW_LOCAL_COUNT]; } - handleNotification(notification) { if (notification.getName() === EventNames.SUBVIEW_LOCAL_COUNT) { - - if (notification.body) { this.view.setViewState({ counterLocal: notification.body.count }) } - - } } - - - onRegister() { // this.facade.addCommand(EventNames.SUBVIEW_LOCAL_COUNT, CounterCommand); }