guillemcordoba / lit-svelte-stores

Lit integration to use svelte stores as cross element state management
MIT License
12 stars 2 forks source link

Constructor property assignment shorthand breaks method context #1

Open pospi opened 1 year ago

pospi commented 1 year ago

At least, I think that's what is happening.

Bumped into this working with the Neighbourhoods Sensemaker store, which is an instance object with Svelte store accessors as fields:

export declare class SensemakerStore {
    //..
    appletConfig(): import("svelte/store").Readable<AppletConfig>;
    //..
}

In my component I want to be able to simple declare this.appletConfig = new StoreSubscriber(this, this.sensemakerStore.appletConfig) but this causes a private property access error to SensemakerStore; instead the fields have to be manually bound like this.appletConfig = new StoreSubscriber(this, this.sensemakerStore.appletConfig.bind(this.sensemakerStore)).

guillemcordoba commented 1 year ago

Hum... I don't really know what's really happening... I assume you meant going this.appletConfig = new StoreSubscriber(this, this.sensemakerStore.appletConfig()), since that accessor is a function that returns a readable? If that's the case, I would need more information and the error message to really know what's the problem.