Skip to content

feat: implement standalone fromContext #51

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

Merged
merged 3 commits into from
Nov 14, 2024
Merged

Conversation

divmain
Copy link
Contributor

@divmain divmain commented Nov 12, 2024

It might be worth looking into how we can consolidate this new fromContext implementation with the state manager's internal fromContext implementation. This new one is much simpler, since it only cares about one variety of context.

Once merged, you will be able to do things like this:

import { fromContext } from '@lwc/state';
import childStateFactory from 'x/childState';
import parentStateFactory from 'x/parentState';
export default class ContextChild extends ContextfulLightningElement {
parentState = fromContext(parentStateFactory);
get nameProvidedByParent() {
return this.parentState.value?.name ?? 'not available';
}
}

@divmain divmain force-pushed the divmain/top-level-fromContext branch 2 times, most recently from 353d682 to 7100fd4 Compare November 13, 2024 04:48
@divmain divmain changed the title feat: implement detached fromContext feat: implement standalone fromContext Nov 13, 2024
@divmain divmain force-pushed the divmain/top-level-fromContext branch from 7100fd4 to 6495c97 Compare November 13, 2024 04:50
@rax-it
Copy link
Contributor

rax-it commented Nov 13, 2024

I thought a bit about separating a base-context signal so that it can be reused in SM and here but I agree with you that this is not much bloat. LMK when this is merged, I can add the disconnectContext stuff as it's already merged now.

divmain and others added 2 commits November 14, 2024 15:17
Co-authored-by: rax-it <rakshit.verma@salesforce.com>
@divmain divmain merged commit 361ece8 into main Nov 14, 2024
3 checks passed
@divmain divmain deleted the divmain/top-level-fromContext branch November 14, 2024 23:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants