Skip to content

Commit

Permalink
rename package (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
koddsson authored Apr 23, 2024
1 parent 348b133 commit 5d8d662
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
# @koddsson/context-protocol
# @open-wc/context-protocol

A Lit compatible implementation of the [context-protocol community protocol](https://github.com/webcomponents-cg/community-protocols/blob/main/proposals/context.md).

## Installation

```sh
npm install --save @koddsson/context-protocol
npm install --save @open-wc/context-protocol
```

## Usage

A component that implements the ProviderMixin will become a _Provider_ of data and a component that implements the ConsumerMixin will become a _Consumer_ of data.

```ts
import { ProviderMixin } from "@koddsson/context-protocol";
import { ProviderMixin } from "@open-wc/context-protocol";

export class ProviderElement extends ProviderMixin(HTMLElement) {
// Set any data contexts here.
Expand All @@ -26,15 +26,15 @@ export class ProviderElement extends ProviderMixin(HTMLElement) {
async connectedCallback() {
// It's also possible to provide context at any point using `updateContext`.

const response = await fetch('/api/messages/');
const response = await fetch("/api/messages/");
const data = await response.json();
this.updateContext('number-of-unread-messages', data.unreadCount);
this.updateContext("number-of-unread-messages", data.unreadCount);
}
}
```

```ts
import { ConsumerMixin } from "@koddsson/context-protocol";
import { ConsumerMixin } from "@open-wc/context-protocol";

export class ConsumerElement extends ConsumerMixin(HTMLElement) {
contexts = {
Expand All @@ -46,7 +46,7 @@ export class ConsumerElement extends ConsumerMixin(HTMLElement) {

connectedCallback() {
// It's also possible to get any context on demand without subscribing.
this.textContent = this.getContext('number-of-unread-messages');
this.textContent = this.getContext("number-of-unread-messages");
}
}
```
4 changes: 2 additions & 2 deletions jsr.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@koddsson/context-protocol",
"version": "0.0.2",
"name": "@open-wc/context-protocol",
"version": "0.0.3",
"exports": "./index.ts"
}
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@koddsson/context-protocol",
"name": "@open-wc/context-protocol",
"version": "0.0.3",
"description": "A Lit compatible implementation of the context-protocol community protocol",
"type": "module",
Expand Down

0 comments on commit 5d8d662

Please sign in to comment.