API Reference
@univerjs
@univerjs/ui
functions
Useobservable

@univerjs/ui v0.4.2Docs


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

ParameterType
observableObservableOrFn<T>
defaultValueundefined | 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

ParameterType
observableNullable<ObservableOrFn<T>>
defaultValueT

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

ParameterType
observableNullable<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

ParameterType
observableNullable<ObservableOrFn<T>>
defaultValueT
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

ParameterType
observableNullable<ObservableOrFn<T>>
defaultValueundefined
shouldHaveSyncValuetrue
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

ParameterType
observableNullable<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)


Copyright © 2021-2024 DreamNum Co,Ltd. All Rights Reserved.