lit / lit/lit

[labs/context] Allow multiple provider contexts to be added at the same time

Open
#3,573 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Good First Issue
Dominant language
TypeScript
Stars
21.8k
Forks
1.1k
Avg merge
18h 25m
Merged PRs (30d)
2

Description

### Should this be an RFC?

- [X] This is not a substantial change

### Which package is this a feature request for?

Context (@lit-labs/context)

### Description

It would be useful to be able to provide multiple contexts at the same time; allowing a provider component to be instantiated the same way but with a dynamic array of contexts

```js
private provider = new MultiContextProvider(this, [
[loggerContext, {
log: (msg) => {
console.log(`[my-app] ${msg}`);
},
}],
[themeContext, myTheme],
[apiContext, myAPI],
]);
```

### Alternatives and Workarounds

It's possible to create a separate provider for every injected service.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the @lit-labs/context provider implementation and its existing Provider API. Add support for constructing one provider with an array of context/value pairs, and verify that multiple injected services can be provided together without requiring separate providers.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.