Skip to content

Commit

Permalink
docs(context): update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
kwaa committed May 20, 2024
1 parent d93b1e4 commit 7fdeff8
Showing 1 changed file with 23 additions and 12 deletions.
35 changes: 23 additions & 12 deletions packages/context/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,23 @@ class MyElement extends LitElement {
}
```

###### consumer

```ts
import { consumer } from '@kkna/context'
import { LitElement, html } from 'lit'

class MyElement extends LitElement {
public processOptions = consumer(this, { subscribe: true })

render() {
return html`<pre><code>
${JSON.stringify(this.processOptions.value, null, 2)}
</code></pre>`
}
}
```

###### provider

```ts
Expand All @@ -64,21 +81,15 @@ const provide = provider(document.body, {
})
```

###### consumer
###### defineConfig (experimental)

```ts
import { consumer } from '@kkna/context'
import { LitElement, html } from 'lit'

class MyElement extends LitElement {
public processOptions = consumer(this, { subscribe: true })
import { defineConfig } from '@kkna/context'

render() {
return html`<pre><code>
${JSON.stringify(this.processOptions.value, null, 2)}
</code></pre>`
}
}
defineConfig({
data: { ...data },
presets: [...presets],
})
```

<!-- ### CDN -->
Expand Down

0 comments on commit 7fdeff8

Please sign in to comment.