Skip to content

Commit

Permalink
fix indentation
Browse files Browse the repository at this point in the history
  • Loading branch information
benStre committed Feb 6, 2024
1 parent a80ec45 commit 9fae977
Show file tree
Hide file tree
Showing 2 changed files with 174 additions and 163 deletions.
42 changes: 21 additions & 21 deletions docs/manual/09 Functional Programming.md
Original file line number Diff line number Diff line change
Expand Up @@ -208,25 +208,25 @@ One way to achieve this is by wrapping the body of a normal function with `alway
```ts
// normal function
const getGreetingMessage = (country: string) => {
switch (country) {
case "de": return "Hallo";
case "fr": return "Bonjour";
case "es": return "Hola";
default: return "Hello";
}
switch (country) {
case "de": return "Hallo";
case "fr": return "Bonjour";
case "es": return "Hola";
default: return "Hello";
}
}

// reactive version
const getGreetingMessageReactive = (country: RefOrValue<string>) => {
// returns a Ref<string> that gets updated reactively
return always(() => {
switch (country) {
case "de": return "Hallo";
case "fr": return "Bonjour";
case "es": return "Hola";
default: return "Hello";
}
})
// returns a Ref<string> that gets updated reactively
return always(() => {
switch (country) {
case "de": return "Hallo";
case "fr": return "Bonjour";
case "es": return "Hola";
default: return "Hello";
}
})
}
```

Expand All @@ -236,12 +236,12 @@ Although the created reactive function is called with `Ref` values, you don't ne
```ts
// reactive function, returns a Ref<string> that gets updated reactively when 'country' changes
const getGreetingMessageReactive = reactiveFn((country: string) => {
switch (country) {
case "de": return "Hallo";
case "fr": return "Bonjour";
case "es": return "Hola";
default: return "Hello";
}
switch (country) {
case "de": return "Hallo";
case "fr": return "Bonjour";
case "es": return "Hola";
default: return "Hello";
}
})

const country: Ref<string> = $$("de");
Expand Down
Loading

0 comments on commit 9fae977

Please sign in to comment.