Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
duart38 committed Aug 5, 2020
1 parent 7a2bee5 commit 5a9d968
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions Observe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,12 @@ export default class Observe<T> {
* @param once Specify wether the bound callback will only be called once (this causes the listeners to be removed thus increasing performance)
* @returns the function used in the listener (can be used to unbind)
*/
public bind(callback: ObservedCallback<T>, once:boolean = false): (e: Event) => void {
public bind(
callback: ObservedCallback<T>,
once: boolean = false,
): (e: Event) => void {
let func = (e: Event) => callback((<CustomEvent> e).detail);
addEventListener(this.eventID, func, {once});
addEventListener(this.eventID, func, { once });
return func;
}
/**
Expand All @@ -72,7 +75,9 @@ export default class Observe<T> {
this.updateHistory(value);
this.emit(value);
} else if (value instanceof Observe) {
let lh = this.getHistory()[this.history.length - 1] as unknown as Observe<any>;
let lh = this.getHistory()[this.history.length - 1] as unknown as Observe<
any
>;
lh.unBind(this.lastNestedBound); // unbind the last bound to
this.lastNestedBound = value.bind((d: T) => this.emit(value)); // bind to new value and store its cb
this.updateHistory(value);
Expand Down

0 comments on commit 5a9d968

Please sign in to comment.