Skip to content
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

Added context documentation #905

Merged
merged 6 commits into from
Sep 6, 2024
Merged

Added context documentation #905

merged 6 commits into from
Sep 6, 2024

Conversation

taras
Copy link
Member

@taras taras commented Aug 30, 2024

Motivation

Context is a killer feature of Effection that we don't have documented on our website.

Approach

  • I "borrowed" way too much inspiration from React Context docs.
  • Added a section about naming conventions that someone asked me about in Discord.

@taras
Copy link
Member Author

taras commented Aug 30, 2024

What's up with this?
image

@taras
Copy link
Member Author

taras commented Aug 30, 2024

@cowboyd why is Lint failing here? https://github.com/thefrontside/effection/actions/runs/10638858208/job/29495674024?pr=905

GitHub
Structured concurrency and effects for JavaScript. Contribute to thefrontside/effection development by creating an account on GitHub.

@taras
Copy link
Member Author

taras commented Aug 30, 2024

@cowboyd I fixed the TOC sidebar but lint is not passing.

@cowboyd
Copy link
Member

cowboyd commented Sep 1, 2024

@taras It looks like maybe line wrap is disabled and so it's wrapping to the same line? not sure.

As for the content, this is really good, and I like cribbing from React. I do think that we should mention these pratical pieces of information:

  1. Context serves the same purpose as "dependency injection" except that it is coupled to lexical scope and not
  2. You can use a resource in combination with a context to initialize a service and "inject it", which is what folks use.
  3. Mabye some discussion around the difference between yield* Context vs yield* Context.get()

@taras
Copy link
Member Author

taras commented Sep 1, 2024

Let's merge what we have and add to it

@cowboyd
Copy link
Member

cowboyd commented Sep 2, 2024

Let's merge what we have and add to it

The thing is that I don't think the advice to wrap in a use helper makes much sense unless it's understood that there are multiple ways to access the context each with different behaviors and that it is generally a good idea to abstract around the access depending on your use-case. By the same token, an initContext() operation doesn't make any sense outside the discussion of services and resources. Why not just call Context.set()? It's because there may be long running things that need to happen as part of setting it up. What might those things be?

I'd be happy to add this as this makes it really easy to slot in.

@taras
Copy link
Member Author

taras commented Sep 2, 2024

@cowboyd I removed the naming convention section. DI should be a separate page in the advanced section.

@taras taras merged commit 29babd7 into v3 Sep 6, 2024
3 checks passed
@taras taras deleted the tm/context-docs branch September 6, 2024 21:31
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