Skip to content

Commit

Permalink
feat: Execute read method after page added
Browse files Browse the repository at this point in the history
  • Loading branch information
gaoli committed Aug 29, 2018
1 parent d38417f commit 25e41d1
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 16 deletions.
4 changes: 1 addition & 3 deletions src/components/Flow/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ class Flow extends Page {
return `${FLOW_CONTAINER}_${editorId}`;
}

init() {
super.init();

initPage() {
const { editor } = this.context;

editor.emit(EVENT_BEFORE_ADD_PAGE, { className: FLOW_CLASS_NAME });
Expand Down
4 changes: 1 addition & 3 deletions src/components/Mind/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ class Mind extends Page {
return `${MIND_CONTAINER}_${editorId}`;
}

init() {
super.init();

initPage() {
const { editor } = this.context;

editor.emit(EVENT_BEFORE_ADD_PAGE, { className: MIND_CLASS_NAME });
Expand Down
29 changes: 19 additions & 10 deletions src/components/Page/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,24 +59,33 @@ class Page extends BaseComponent {
return false;
}

init() {
this.mixConfig();
get graph() {
return this.page.getGraph();
}

initPage() {}

readData() {
const { data } = this.props;

if (data) {
this.page.read(data);
}
}

addListener = (target, eventName, handler) => {
if (typeof handler === 'function') target.on(eventName, handler);
}

mixConfig() {
init() {
merge(this.config, this.props, {
graph: {
container: this.pageId,
},
});
}

get graph() {
return this.page.getGraph();
}

addListener = (target, eventName, handler) => {
if (typeof handler === 'function') target.on(eventName, handler);
this.initPage();
this.readData();
}

bindEvent() {
Expand Down

0 comments on commit 25e41d1

Please sign in to comment.