Skip to content

Commit a74bfed

Browse files
authored
feat(composition-api): add overload for inject factory (#662)
1 parent 331758f commit a74bfed

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/api/composition-api.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,12 @@ function provide<T>(key: InjectionKey<T> | string, value: T): void
135135
function inject<T>(key: InjectionKey<T> | string): T | undefined
136136
// with default value
137137
function inject<T>(key: InjectionKey<T> | string, defaultValue: T): T
138+
// with factory
139+
function inject<T>(
140+
key: InjectionKey<T> | string,
141+
defaultValue: () => T,
142+
treatDefaultAsFactory: true
143+
): T
138144
```
139145

140146
Vue provides an `InjectionKey` interface which is a generic type that extends `Symbol`. It can be used to sync the type of the injected value between the provider and the consumer:

0 commit comments

Comments
 (0)