@univerjs/ui v0.4.2 • Docs
Function: useObservable()
A hook to subscribe to an observable and get the latest value.
Param
The observable to subscribe to.
Param
When the observable would not emit any value, the default value would be returned.
Param
If true, the observable should emit a value synchronously.
Param
The dependencies to trigger a re-subscription.
useObservable(observable, defaultValue, shouldHaveSyncValue)
function useObservable<T>(
observable,
defaultValue,
shouldHaveSyncValue?): T
A hook to subscribe to an observable and get the latest value.
Type Parameters
Type Parameter |
---|
T |
Parameters
Parameter | Type |
---|---|
observable | ObservableOrFn <T > |
defaultValue | undefined | T |
shouldHaveSyncValue ? | true |
Returns
T
Param
The observable to subscribe to.
Param
When the observable would not emit any value, the default value would be returned.
Param
If true, the observable should emit a value synchronously.
Param
The dependencies to trigger a re-subscription.
Defined in
packages/ui/src/components/hooks/observable.ts:33 (opens in a new tab)
useObservable(observable, defaultValue)
function useObservable<T>(observable, defaultValue): T
A hook to subscribe to an observable and get the latest value.
Type Parameters
Type Parameter |
---|
T |
Parameters
Parameter | Type |
---|---|
observable | Nullable <ObservableOrFn <T >> |
defaultValue | T |
Returns
T
Param
The observable to subscribe to.
Param
When the observable would not emit any value, the default value would be returned.
Param
If true, the observable should emit a value synchronously.
Param
The dependencies to trigger a re-subscription.
Defined in
packages/ui/src/components/hooks/observable.ts:34 (opens in a new tab)
useObservable(observable, defaultValue)
function useObservable<T>(observable, defaultValue?): T | undefined
A hook to subscribe to an observable and get the latest value.
Type Parameters
Type Parameter |
---|
T |
Parameters
Parameter | Type |
---|---|
observable | Nullable <ObservableOrFn <T >> |
defaultValue ? | undefined |
Returns
T
| undefined
Param
The observable to subscribe to.
Param
When the observable would not emit any value, the default value would be returned.
Param
If true, the observable should emit a value synchronously.
Param
The dependencies to trigger a re-subscription.
Defined in
packages/ui/src/components/hooks/observable.ts:35 (opens in a new tab)
useObservable(observable, defaultValue, shouldHaveSyncValue, deps)
function useObservable<T>(
observable,
defaultValue,
shouldHaveSyncValue?,
deps?): T
A hook to subscribe to an observable and get the latest value.
Type Parameters
Type Parameter |
---|
T |
Parameters
Parameter | Type |
---|---|
observable | Nullable <ObservableOrFn <T >> |
defaultValue | T |
shouldHaveSyncValue ? | boolean |
deps ? | any [] |
Returns
T
Param
The observable to subscribe to.
Param
When the observable would not emit any value, the default value would be returned.
Param
If true, the observable should emit a value synchronously.
Param
The dependencies to trigger a re-subscription.
Defined in
packages/ui/src/components/hooks/observable.ts:36 (opens in a new tab)
useObservable(observable, defaultValue, shouldHaveSyncValue, deps)
function useObservable<T>(
observable,
defaultValue,
shouldHaveSyncValue,
deps?): T
A hook to subscribe to an observable and get the latest value.
Type Parameters
Type Parameter |
---|
T |
Parameters
Parameter | Type |
---|---|
observable | Nullable <ObservableOrFn <T >> |
defaultValue | undefined |
shouldHaveSyncValue | true |
deps ? | any [] |
Returns
T
Param
The observable to subscribe to.
Param
When the observable would not emit any value, the default value would be returned.
Param
If true, the observable should emit a value synchronously.
Param
The dependencies to trigger a re-subscription.
Defined in
packages/ui/src/components/hooks/observable.ts:37 (opens in a new tab)
useObservable(observable, defaultValue, shouldHaveSyncValue, deps)
function useObservable<T>(
observable,
defaultValue?,
shouldHaveSyncValue?,
deps?): T | undefined
A hook to subscribe to an observable and get the latest value.
Type Parameters
Type Parameter |
---|
T |
Parameters
Parameter | Type |
---|---|
observable | Nullable <ObservableOrFn <T >> |
defaultValue ? | T |
shouldHaveSyncValue ? | boolean |
deps ? | any [] |
Returns
T
| undefined
Param
The observable to subscribe to.
Param
When the observable would not emit any value, the default value would be returned.
Param
If true, the observable should emit a value synchronously.
Param
The dependencies to trigger a re-subscription.
Defined in
packages/ui/src/components/hooks/observable.ts:38 (opens in a new tab)