본문으로 건너뛰기

ReactiveSubscribe

ReactiveSubscribe(Constructor: any): void

Parameters

Constructor

any

Description

ReactiveSubscribe is a class decorator and adds .subscribe and .unsubscribe methods.

Example
import { ReactiveSubscribe, Observe } from "@cfcs/core";

@ReactiveSubscribe
class Component {
@Observe value1 = 1;

constructor() {
requestAnimationFrame(() => {
this.value1 = 2;
});
}
}

interface Component extends ReactiveSubscribe<{
value1: number;
value2: number;
}> {}

const component = new Component();

// 1
console.log(component.value1);

component.subscribe("value1", nextValue => {
// When the change event occurs => (2, 2)
console.log(nextValue, component.value2);
});