-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This PR adds a new API that will allow decoupling injection targets from graphs.
- Loading branch information
Showing
26 changed files
with
237 additions
and
48 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
packages/documentation/docs/documentation/usage/ServiceLocator.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
--- | ||
sidebar_position: 1 | ||
sidebar_position: 2 | ||
title: 'Observable' | ||
tags: [Observable, Reactivity] | ||
--- | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
--- | ||
sidebar_position: 1 | ||
title: 'Obsidian' | ||
tags: [Service Locator] | ||
--- | ||
|
||
`Obsidian` **exposes a set of functions that allow you to interact with the Obsidian framework imperatively.** | ||
|
||
* [Reference](#reference) | ||
* [obtain(keyOrGraph, props?)](#obtainkeyorgraph-props) | ||
* [registerGraph(key, graphGenerator)](#registergraphkey-graphgenerator) | ||
* [inject(target, keyOrGraph)](#injecttarget-keyorgraph) | ||
___ | ||
|
||
## Reference | ||
### obtain(keyOrGraph, props?): ServiceLocator | ||
The `obtain` function is used to obtain a graph instance to be used as a [service locator](https://en.wikipedia.org/wiki/Service_locator_pattern). | ||
|
||
#### Arguments | ||
* `keyOrGraph?` - The class reference of the graph or its corresponding key if it was registered with a key. | ||
* `props?` - An object containing props to be passed to the graph's constructor if this is the first time the graph is being instantiated. | ||
|
||
#### Returns | ||
* `ServiceLocator` - A service locator instance that can be used to resolve dependencies from the graph. | ||
|
||
### registerGraph(key, graphGenerator) | ||
The `registerGraph` function is used to register a graph generator function with a key. This allows the graph to be instantiated using the key instead of the class reference. This is useful when you want to decouple the graph's instantiation from its usage. | ||
|
||
#### Arguments | ||
* `key` - The key to register the graph with. | ||
* `graphGenerator` - A function that returns the graph class reference. The generator function is called only when the graph is being instantiated. It's recommended to retrieve the class reference using inline require to delay side effects until the graph is actually used. | ||
|
||
### inject(target, keyOrGraph) | ||
The `inject` function is used to inject dependencies annotated with the `@LateInject` decorator into a class instance. | ||
|
||
#### Arguments | ||
* `target` - The class instance to inject the dependencies into. | ||
* `keyOrGraph` - The class reference of the graph or its corresponding key if it was registered with a key. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
--- | ||
sidebar_position: 3 | ||
sidebar_position: 4 | ||
title: 'useObserver' | ||
tags: [useObserver, Reactivity] | ||
--- | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
--- | ||
sidebar_position: 4 | ||
sidebar_position: 5 | ||
title: 'useObservers' | ||
tags: [useObservers, Reactivity] | ||
--- | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 10 additions & 3 deletions
13
packages/react-obsidian/src/injectors/class/LateInjector.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.