-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Any plan to use lit 2.0 controllers ? #7
Comments
Hi @christophe-g, sorry I haven't replied to this yet. I haven't looked into this new technology of Lit, and currently don't have much time for it either. I would like to look into it when I have more time, so I'll keep you updated about it. Thanks for the suggestion anyway :). |
No problem,
I so understand that! I haven't played with controllers yet, but from what I got, they could (possibly greatly) simplify how lit-state checks state changes and re-trigger a requestUpdate. |
I agree with the above, but having played with controllers I’m still using lit-state. The biggest difference I see between them is that it seems like a controller is almost just an extension of the lit element. Or to put it another way, you have 1 controller for 1 element. The great advantage of lit-state is that multiple elements can hook into a single state object. |
Hmm, I think the idea would be to use the controller(s) as an interface between ONE state object and multiple elements. If that is not possible, forget about my suggestion ; ) |
Yes, I guess your suggestion would be to use Lit controllers inside LitState? |
The idea would be to use a controller instead of a mixin to connect a component to a store: Translating from the readme example, you could do this: import {LitElement, html} from 'lit-element';
import {StateController} from 'lit-element-state';
import {myState} from './my-state.js';
class MyComponent extends LitElement {
private _state = new StateController(this);
render() {
return html`
<h1>Counter: ${myState.counter}</h1>
<button @click=${() => myState.counter++}></button>
`;
}
} but perhaps it would be nice to have a direct connection between a component and the state it uses so you could also pass the state to the controller: class MyComponent extends LitElement {
private _state = new StateController(this, [myState]);
} |
@justinfagnani |
Hey @madeInLagny Tu peux jeter un coup d'oeil at https://github.com/lit-apps/lit-app/tree/main/packages/state Source is TS though. |
This is great and really what I am looking for. But I'd like to use a non TS version. Is anyone aware of an existing repo? |
I am sure you know this, but you can consume this in a js project. The only
thing that might be offsetting is the use of decorators. You can still
declare state properties as static properties of the State (exactly as you
would do for a Lit-Element) - without decorators.
…On Wed, May 3, 2023 at 3:10 PM madeInLagny ***@***.***> wrote:
This is great and really what I am looking for. But I'd like to use a non
TS version. Is anyone aware of an existing repo?
—
Reply to this email directly, view it on GitHub
<#7 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAI5FNLZLO33ARRBUZGCAWDXEJKMJANCNFSM43S36TGQ>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
--
<https://preignition.org/>
Christophe Geiser / CTO
We are defined by the lines we choose to cross or to be confined by
Co-Founder of preignition.org / accessiblesurveys.com
|
Controllers don't have anything to do with TypeScript. They're just objects that call Then you implement controller callbacks like Is there anything specific you're having problems with? This discussion might be off-topic for this repo/thread though. Feel free to open something in https://github.com/lit/lit/discussions |
Hey @gitaarik
Just curious to know if there are plans to upgrade to lit 2.0 now that it is on release candidate stage?
Apparently controllers would be perfectly fitted to lit-state : https://lit.dev/docs/composition/controllers/
The text was updated successfully, but these errors were encountered: