Skip to content

Commit

Permalink
add: event support
Browse files Browse the repository at this point in the history
  • Loading branch information
afeiship committed Jan 6, 2020
1 parent 7776cf6 commit ed6959d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions build/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export default merge(baseConfig, {
}),
externals: externals.base({
'@feizheng/noop': '@feizheng/noop',
'event-mitt':'event-mitt',
lodash: 'lodash'
}),
plugins: [plugins.clean(), plugins.copyStyles()]
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
"react-dom": "^16.8.5"
},
"dependencies": {
"@feizheng/event-mitt": "^2.0.3",
"@feizheng/noop": "^1.0.0",
"classnames": "^2.2.6",
"lodash": "^4.17.15",
Expand Down
4 changes: 4 additions & 0 deletions src/components/lib/store.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,27 @@
import { get } from 'lodash';
import EventMitt from '@feizheng/event-mitt';

export default class {
constructor(inModals, inContext, inName) {
this.modals = inModals;
this.context = inContext;
this.name = inName;
Object.assign(this, EventMitt);
}

present(inName, inData) {
const name = inName || this.name;
const data = inData || {};
this.modals[name] = { visible: true, data };
this.context.setState({ modals: this.modals });
this.emit(`${name}:present`);
}

dismiss(inName) {
const name = inName || this.name;
this.modals[name] = { visible: false, data: {} };
this.context.setState({ modals: this.modals });
this.emit(`${name}:dismiss`);
}

visible(inName) {
Expand Down

0 comments on commit ed6959d

Please sign in to comment.