This webcomponents will pass context as props in child webcomponents.
attachWayContext has one parameter, a referance to component you want context in.
Provider will append context as attributes.
For now it only support shallow object as context, so no object in context.
Docs at way-provider-docs.vercel.app
⚡️ When using all prop you don't need attachWayContext, all the webcomponents in the tree will be initalized with those props
Wrap your components with provider
import 'way-provider';
<way-provider context="{'name': 'consumer'}">
...children components
</way-provider>
Initalize context in your webcomponent child
import { attachWayContext } from 'way-provider';
...
connectedCallback(){
attachWayContext(this)
}
thisCmp = get_current_component()
onMount(() => attachWayContext(thisCmp))
Use the attribute
this.getAttribute('name');
@property()
name: string
export let name
This library is not using default customElement decorator so don't worry if it's imported multiple times, the way-provider will not throw an error and will be defined just once.
Built using Lit and Vite