File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -105,6 +105,15 @@ export class Store<T> implements Subject<T> {
105105 */
106106 public get state ( ) : T { return structuredClone ( this . #state) as T ; }
107107
108+ /**
109+ * Convenience method to create a unique pointer.
110+ *
111+ * @returns A `Pointer`
112+ */
113+ static newPointer ( ) : string {
114+ return crypto . randomUUID ( ) ;
115+ }
116+
108117 /**
109118 * Creates a new `Store` (aka {@link Subject}) that can be subscribed to, or observed for a state change.
110119 */
Original file line number Diff line number Diff line change @@ -50,6 +50,12 @@ Deno.test("A new Store can be created", () => {
5050 assertEquals ( store . state , state , `store.state should be equal to "${ state } "` ) ;
5151} ) ;
5252
53+ Deno . test ( "A store can generate a pointer" , ( ) => {
54+ const pointer = mod . Store . newPointer ( ) ;
55+
56+ assertEquals ( typeof pointer , "string" , "pointer should be a string" ) ;
57+ } ) ;
58+
5359Deno . test ( "A new observer can be created" , ( ) => {
5460 class ConcreteObserver implements mod . Observer < void > {
5561 public update ( _subject : mod . Store < void > ) : void {
You can’t perform that action at this time.
0 commit comments