From 0e63c766702cad1fe0da09bdaaeade7cde78f522 Mon Sep 17 00:00:00 2001 From: anticultist <33195947+anticultist@users.noreply.github.com> Date: Tue, 16 Apr 2024 08:55:38 +0200 Subject: [PATCH] add some new lines --- packages/reactivity-core/README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/reactivity-core/README.md b/packages/reactivity-core/README.md index 208f3eb..96ed257 100644 --- a/packages/reactivity-core/README.md +++ b/packages/reactivity-core/README.md @@ -346,23 +346,29 @@ type PersonType = { firstName: string; lastName: string; } + // define a class like PersonClass const PersonClass = reactiveStruct().define({ firstName: {}, // default options (reactive and writable) lastName: { writable: false } // read-only }); + // create a new reactive instance const person = new PersonClass({ firstName: "John", lastName: "Doe" }); + // compute the full name const fullName = computed(() => `${person.firstName} ${person.lastName}`); console.log(fullName.value); // John Doe + person.firstName = "Jane"; console.log(fullName.value); // Jane Doe ``` + The `define` function can be used to + - make properties read-only - declare non reactive properties - create computed properties @@ -377,6 +383,7 @@ type PersonType = { fullName: string; // will be a computed property printName: () => void // a method printing the full name } + const PersonClass = reactiveStruct().define({ firstName: {}, lastName: { writable: false }, @@ -393,6 +400,7 @@ const PersonClass = reactiveStruct().define({ } } }); + // create a new reactive instance const person = new PersonClass({ firstName: "John",