@kkna/context
v0.0.4
Published
<!-- automd:badges color="gray" license -->
Downloads
9
Readme
@kkna/context
Usage
NPM
install
# npm
npm install @kkna/context
# yarn
yarn add @kkna/context
# pnpm
pnpm install @kkna/context
# bun
bun install @kkna/context
context
import { context } from '@kkna/context'
import { consume } from '@lit/context'
import { LitElement, html } from 'lit'
class MyElement extends LitElement {
@consume({ context, subscribe: true })
public processOptions?: ProcessOptions
render() {
return html`<pre><code>
${JSON.stringify(this.processOptions, null, 2)}
</code></pre>`
}
}
consumer
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
import { provider } from '@kkna/context'
const provide = provider(document.body, {
initialValue: {
data: { ...data },
presets: [...presets],
},
})
defineConfig (experimental)
import { defineConfig } from '@kkna/context'
defineConfig({
data: { ...data },
presets: [...presets],
})
License
MIT