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

Support registering graphs #188

Merged
merged 9 commits into from
Oct 31, 2024
Merged

Support registering graphs #188

merged 9 commits into from
Oct 31, 2024

Conversation

guyca
Copy link
Collaborator

@guyca guyca commented Oct 28, 2024

This PR adds a new API that will allow decoupling injection targets from graphs.

API

Registering a graph

Registering a graph will let you use it by its registered key.

Obsidian.registerGraph('FooGraph', () => require('some/path/FooGraph).default);

injectHook

Inject your target with the key used to register the graph.

export const useFoo = injectHook(useFooHook, 'FooGraph');

Obsidian.obtain

Registered graphs can still be used as service locators.

import type FooGraph from 'some/path/FooGraph';

Obsidian.obtain<FooGraph>('FooGraph').foo();

Tasks

  • obtain registered graphs
  • inject hooks
  • inject components
  • late inject
  • @Injectable(key)
  • registered subgraphs [ON HOLD: breaks the unresolved dependencies ESLint rule]
  • documentation

@guyca guyca marked this pull request as draft October 28, 2024 19:05
@guyca guyca marked this pull request as ready for review October 31, 2024 12:34
@guyca guyca merged commit 4ef5c2a into master Oct 31, 2024
2 checks passed
@guyca guyca deleted the registerGraph branch October 31, 2024 14:01
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.

1 participant