-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
052b965
commit 48caeeb
Showing
11 changed files
with
52 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,24 @@ | ||
import {bind} from '@exadel/esl'; | ||
import {ObserverCallback} from '@exadel/esl'; | ||
import {ESLBaseElement} from '@exadel/esl/modules/esl-base-element/core'; | ||
import {EventUtils} from '@exadel/esl/modules/esl-utils/dom/events'; | ||
import {UIPStateModel} from '../utils/state-model/state-model'; | ||
import {UIPStateModel} from './state-model'; | ||
|
||
export class UIPRoot extends ESLBaseElement { | ||
public static is = 'uip-root'; | ||
private _model: UIPStateModel; | ||
private _model = new UIPStateModel(); | ||
|
||
public get model(): UIPStateModel { | ||
return this._model; | ||
} | ||
|
||
public set model(model: UIPStateModel) { | ||
this._model = model; | ||
} | ||
|
||
protected connectedCallback() { | ||
super.connectedCallback(); | ||
this.bindEvents(); | ||
this.model = new UIPStateModel(); | ||
} | ||
|
||
protected disconnectedCallback() { | ||
this.unbindEvents(); | ||
super.disconnectedCallback(); | ||
} | ||
|
||
protected bindEvents() { | ||
this.addEventListener('request:change', this._onStateChange); | ||
} | ||
|
||
protected unbindEvents() { | ||
this.removeEventListener('request:change', this._onStateChange); | ||
public addStateListener(listener: ObserverCallback) { | ||
this._model.addListener(listener); | ||
} | ||
|
||
@bind | ||
protected _onStateChange(e: CustomEvent) { | ||
this.model.html = e.detail.markup; | ||
const detail = Object.assign({ | ||
origin: e.target | ||
}, e.detail); | ||
EventUtils.dispatch(this, 'state:change', {detail}); | ||
public removeStateListener(listener: ObserverCallback) { | ||
this._model.removeListener(listener); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters