INIT
This commit is contained in:
+24
@@ -0,0 +1,24 @@
|
||||
import { createSubscriber } from './create-subscriber.js';
|
||||
|
||||
/**
|
||||
* @template T
|
||||
*/
|
||||
export class ReactiveValue {
|
||||
#fn;
|
||||
#subscribe;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {() => T} fn
|
||||
* @param {(update: () => void) => void} onsubscribe
|
||||
*/
|
||||
constructor(fn, onsubscribe) {
|
||||
this.#fn = fn;
|
||||
this.#subscribe = createSubscriber(onsubscribe);
|
||||
}
|
||||
|
||||
get current() {
|
||||
this.#subscribe();
|
||||
return this.#fn();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user