Package-level declarations

Types

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
data class BooleanHolder(val state: State<Boolean>, val toggle: ToggleFn, val setValue: SetValueFn<Boolean>, val setTrue: SetTrueFn, val setFalse: SetFalseFn)
Link copied to clipboard
data class CopyPasteHolder(val copy: CopyFn, val paste: PasteFn)
Link copied to clipboard
data class CountdownHolder(val timeLeft: State<Duration>, val formatRes: State<FormattedRes>)
Link copied to clipboard

Countdown options

Link copied to clipboard
data class CounterHolder(val state: State<Int>, val inc: IncFn, val dec: DecFn, val setValue: SetValueFn<SetterEither<Int>>, val reset: ResetFn)
Link copied to clipboard
data class CounterOptions
Link copied to clipboard
data class DebounceOptions

Debounce options

Link copied to clipboard
typealias Dispatch<A> = (A) -> Unit
Link copied to clipboard
typealias DispatchAsync<A> = (block: suspend CoroutineScope.(Dispatch<A>) -> A) -> Unit
Link copied to clipboard
data class FormattedRes(val days: Int, val hours: Int, val minutes: Int, val seconds: Int, val milliseconds: Int)
Link copied to clipboard
data class GetStateHolder<T>(val state: State<T>, val setValue: SetValueFn<SetterEither<T>>, val getValue: GetValueFn<T>)
Link copied to clipboard
data class ImmutableListHolder<T>(val list: State<PersistentList<T>>, val mutate: (mutator: (MutableList<T>) -> Unit) -> Unit)
Link copied to clipboard
data class IntervalHolder(val resume: ResumeFn, val pause: PauseFn, val isActive: IsActive)
Link copied to clipboard
data class IntervalOptions

Interval options

Link copied to clipboard
data class KeyboardHolder(val hideKeyboard: HideKeyboardFn, val showKeyboard: ShowKeyboardFn)
Link copied to clipboard
typealias Middleware<S, A> = (dispatch: Dispatch<A>, state: S) -> Dispatch<A>
Link copied to clipboard
class MutableRef<T>(initialValue: T) : Ref<T>

Mutable ref

Link copied to clipboard
object None
Link copied to clipboard
abstract class Options<T>(val creator: () -> T)

Description: 规范Options的形式

Link copied to clipboard
data class PersistentHolder<T>(val state: State<T>, val save: SaveToPersistent<T>, val clear: HookClear)

The final return value of the persistence hook is a tuple like state,setState

Link copied to clipboard
interface ReactContext<T>
Link copied to clipboard
typealias Reducer<S, A> = (prevState: S, action: A) -> S
Link copied to clipboard
data class ReducerHolder<S, A>(val state: State<S>, val dispatch: Dispatch<A>, val dispatchAsync: DispatchAsync<A>)
Link copied to clipboard
sealed interface Ref<T>

Read-only Ref interface

Link copied to clipboard
data class ResetStateHolder<T>(val state: State<T>, val setValue: SetValueFn<SetterEither<T>>, val getValue: GetValueFn<T>, val reset: ResetFn)
Link copied to clipboard
data class Single<out A>(val first: A)
Link copied to clipboard
typealias SuspendNormalFunction<TData> = suspend (TParams) -> TData
Link copied to clipboard
data class ThrottleOptions

Throttle options

Link copied to clipboard
data class TimestampHolder(val state: State<Long>, val pause: PauseFn, val resume: ResumeFn, val isActive: IsActive)
Link copied to clipboard

Description: useTimestampuseTimestampRef的配置项

Link copied to clipboard
data class TimestampRefHolder(val ref: Ref<Long>, val pause: PauseFn, val resume: ResumeFn, val isActive: IsActive)
Link copied to clipboard
typealias Tuple0 = None
Link copied to clipboard
typealias Tuple1<A> = Single<A>
Link copied to clipboard
typealias Tuple10<A, B, C, D, E, F, G, H, I, J> = arrow.core.Tuple10<A, B, C, D, E, F, G, H, I, J>
Link copied to clipboard
typealias Tuple2<A, B> = Pair<A, B>
Link copied to clipboard
typealias Tuple3<A, B, C> = Triple<A, B, C>
Link copied to clipboard
typealias Tuple4<A, B, C, D> = arrow.core.Tuple4<A, B, C, D>
Link copied to clipboard
typealias Tuple5<A, B, C, D, E> = arrow.core.Tuple5<A, B, C, D, E>
Link copied to clipboard
typealias Tuple6<A, B, C, D, E, F> = arrow.core.Tuple6<A, B, C, D, E, F>
Link copied to clipboard
typealias Tuple7<A, B, C, D, E, F, G> = arrow.core.Tuple7<A, B, C, D, E, F, G>
Link copied to clipboard
typealias Tuple8<A, B, C, D, E, F, G, H> = arrow.core.Tuple8<A, B, C, D, E, F, G, H>
Link copied to clipboard
typealias Tuple9<A, B, C, D, E, F, G, H, I> = arrow.core.Tuple9<A, B, C, D, E, F, G, H, I>
Link copied to clipboard
data class UndoHolder<T>(val undoState: State<UndoState<T>>, val setValue: SetValueFn<T>, val resetValue: ResetValueFn<T>, val undo: UndoFn, val redo: RedoFn, val canUndo: CanUndo, val canRedo: CanRedo)
Link copied to clipboard
data class UndoState<T>(var past: PersistentList<T> = persistentListOf(), var present: T, var future: PersistentList<T> = persistentListOf())
Link copied to clipboard
data class UseNowOptions(var interval: Duration = 1.seconds, var format: (Long) -> String? = null)

Properties

Link copied to clipboard
val PersistentContext: ReactContext<Triple<PersistentGet, PersistentSave, PersistentClear>>

By default, CacheManager.cache is used for memory persistence. usePersistent is a lightweight encapsulation, you need to provide your own persistence solution globally through PersistentContext.Provider;

Functions

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

A nullable version of useGetState

Link copied to clipboard
fun <T> _useState(default: T): MutableState<T>

这是一个可空的useState,如果对象的状态可能为空,应该使用它。

Link copied to clipboard
fun <T> KFunction<T?>.asNoopFn(instance: Any? = null): (TParams) -> T?

用来将任意一个函数转换成 noop 函数。但是需要注意,如果这个函数是一个实例的函数,必须要传入对应的实例。

Link copied to clipboard
fun <T : Any> KFunction<T>.asSuspendNoopFn(instance: Any? = null): suspend (TParams) -> T

将一个 suspend 挂起函数转换成suspend 版本的 NormalFunction 函数。 直接使用 asNoopFn 会抛出异常,因为挂起函数的参数比参数列表还多一个挂起相关标识。

Link copied to clipboard
fun <T> createContext(initialValue: T): ReactContext<T>

function to create a context object.

Link copied to clipboard
operator fun <T> Ref<T>.getValue(thisObj: Any?, property: KProperty<*>): T
Link copied to clipboard
operator fun <T> SetValueFn<SetterEither<T>>.invoke(leftValue: T)
operator fun <T> SetValueFn<SetterEither<T>>.invoke(rightValue: (T) -> T)
operator fun VoidFunction.invoke(vararg params: Any?)

operator fun <TData> NormalFunction<TData>.invoke(vararg params: Any?): TData

优化函数调用形式,将导出的函数伪装成普通函数的样子,无需对参数进行arrayOf,可能需要手动导包:

Link copied to clipboard
fun LaunchedDebounceEffect(vararg keys: Any?, optionsOf: DebounceOptions.() -> Unit = {}, block: SuspendAsyncFn)
Link copied to clipboard
fun LaunchedThrottleEffect(vararg keys: Any?, optionsOf: ThrottleOptions.() -> Unit = {}, block: SuspendAsyncFn)
Link copied to clipboard
fun <T> SetValueFn<SetterEither<T>>.left(): SetValueFn<T>

退化函数调用,将SetValueFn<SetterEither<T>>转换为SetValueFn<T>,方便使用

Link copied to clipboard

you should call this function in your PersistentSave fun to notify state update

Link copied to clipboard

Observe Ref as State

Link copied to clipboard
operator fun <A, B, C, D, E> Tuple4<A, B, C, D>.plus(e: E): Tuple5<A, B, C, D, E>
operator fun <A, B, C, D, E, F> Tuple5<A, B, C, D, E>.plus(f: F): Tuple6<A, B, C, D, E, F>
operator fun <A, B, C, D, E, F, G> Tuple6<A, B, C, D, E, F>.plus(g: G): Tuple7<A, B, C, D, E, F, G>
operator fun <A, B, C, D, E, F, G, H> Tuple7<A, B, C, D, E, F, G>.plus(h: H): Tuple8<A, B, C, D, E, F, G, H>
operator fun <A, B, C, D, E, F, G, H, I> Tuple8<A, B, C, D, E, F, G, H>.plus(i: I): Tuple9<A, B, C, D, E, F, G, H, I>
operator fun <A, B, C, D, E, F, G, H, I, J> Tuple9<A, B, C, D, E, F, G, H, I>.plus(j: J): Tuple10<A, B, C, D, E, F, G, H, I, J>
operator fun <A, B, C> Pair<A, B>.plus(c: C): Triple<A, B, C>
operator fun <A, B, C, D> Triple<A, B, C>.plus(d: D): Tuple4<A, B, C, D>
Link copied to clipboard
fun rememberAsync(): AsyncRunFn
fun rememberAsync(fn: SuspendAsyncFn): () -> Unit
Link copied to clipboard
fun <T> rememberAutoReset(default: T & Any, interval: Duration): MutableState<T & Any>
Link copied to clipboard
fun rememberBackToFrontEffect(vararg keys: Any?, effect: () -> Unit)
Link copied to clipboard

更符合 Compose 的函数命名方式

Link copied to clipboard
fun rememberBiometric(optionsOf: BiometricOptions.() -> Unit = {}): Pair<() -> Unit, State<Boolean>>
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun rememberCounter(initialValue: Int = 0, optionsOf: CounterOptions.() -> Unit): CounterHolder
Link copied to clipboard
fun <T> rememberCreation(vararg keys: Any?, factory: () -> T): Ref<T>
Link copied to clipboard
fun <S> rememberDebounce(value: S, optionsOf: DebounceOptions.() -> Unit = {}): State<S>
Link copied to clipboard
fun rememberDebounceFn(fn: VoidFunction, optionsOf: DebounceOptions.() -> Unit = {}): (TParams) -> Unit
Link copied to clipboard
fun rememberDisableScreenshot(): Triple<DisableFn, EnableFn, IsDisabled>
Link copied to clipboard
inline fun <A> rememberDispatch(alias: String? = null): Dispatch<A>

更符合 Compose 的函数命名方式

Link copied to clipboard
inline fun <A> rememberDispatchAsync(alias: String? = null, noinline onBefore: DispatchCallback<A>? = null, noinline onFinally: DispatchCallback<A>? = null): DispatchAsync<A>
Link copied to clipboard
Link copied to clipboard
inline fun <T : Any> rememberEventPublish(): (T) -> Unit
Link copied to clipboard
inline fun <T : Any> rememberEventSubscribe(noinline subscriber: (T) -> Unit)
Link copied to clipboard
fun rememberFlashlight(): Pair<TurnOnFn, TurnOffFn>
Link copied to clipboard
Link copied to clipboard
fun rememberFrontToBackEffect(vararg keys: Any?, effect: () -> Unit)
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun rememberInterval(optionsOf: IntervalOptions.() -> Unit = {}, block: () -> Unit): IntervalHolder
fun rememberInterval(optionsOf: IntervalOptions.() -> Unit = {}, ready: Boolean, block: () -> Unit)
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun rememberMount(fn: SuspendAsyncFn)
Link copied to clipboard
fun rememberNow(optionsOf: UseNowOptions.() -> Unit = {}): State<String>
Link copied to clipboard
fun <T> rememberPersistent(key: String, defaultValue: T): PersistentHolder<T>
Link copied to clipboard
fun <T> rememberPrevious(present: T): State<T?>
Link copied to clipboard
fun <S, A> rememberReducer(reducer: Reducer<S, A>, initialState: S, middlewares: Array<Middleware<S, A>> = emptyArray()): ReducerHolder<S, A>
Link copied to clipboard
fun <T> rememberRef(default: T): MutableRef<T>
Link copied to clipboard
fun <TData : Any> rememberRequest(requestFn: SuspendNormalFunction<TData>, optionsOf: RequestOptions<TData>.() -> Unit = {}, plugins: Array<@Composable (RequestOptions<TData>) -> Plugin<TData>> = emptyArray()): RequestHolder<TData>
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
inline fun <T> rememberSelector(alias: String? = null): State<T>
inline fun <T, R> rememberSelector(alias: String? = null, crossinline block: T.() -> R): State<R>
Link copied to clipboard
fun rememberSensor(sensorType: Int, onAccuracyChangedFn: (Sensor, Int) -> Unit = { _, _ -> }, onSensorChangedFn: (SensorEvent) -> Unit = { _ -> })
Link copied to clipboard
Link copied to clipboard
fun <S> rememberThrottle(value: S, optionsOf: ThrottleOptions.() -> Unit = {}): State<S>
Link copied to clipboard
fun rememberThrottleFn(fn: VoidFunction, optionsOf: ThrottleOptions.() -> Unit = {}): (TParams) -> Unit
Link copied to clipboard
fun rememberTimeout(delay: Duration = 1.seconds, block: () -> Unit)
Link copied to clipboard
fun rememberTimestamp(optionsOf: TimestampOptions.() -> Unit = {}, autoResume: Boolean = true): TimestampHolder
Link copied to clipboard
fun rememberTimestampRef(optionsOf: TimestampOptions.() -> Unit = {}, autoResume: Boolean = true): TimestampRefHolder
Link copied to clipboard
fun <T> rememberToggle(defaultValue: T? = null, reverseValue: T? = null): Pair<T?, ToggleFn>
Link copied to clipboard
fun <L, R> rememberToggleEither(defaultValue: L? = null, reverseValue: R? = null): Pair<Either<L?, R?>, ToggleFn>
Link copied to clipboard
fun rememberToggleVisible(isVisible: Boolean = false, content: @Composable () -> Unit): Pair<ComposeComponent, ToggleFn>
fun rememberToggleVisible(isFirst: Boolean = true, content1: @Composable () -> Unit, content2: @Composable () -> Unit): Pair<ComposeComponent, ToggleFn>
Link copied to clipboard
fun <T> rememberUndo(initialPresent: T): UndoHolder<T>
Link copied to clipboard
fun rememberUnmount(block: () -> Unit)
Link copied to clipboard
Link copied to clipboard
fun rememberUpdateEffect(vararg keys: Any?, block: SuspendAsyncFn)
Link copied to clipboard
fun rememberVibrate(): Pair<() -> Unit, () -> Unit>
Link copied to clipboard
fun rememberWakeLock(): Triple<RequestFn, ReleaseFn, IsActive>
Link copied to clipboard
fun rememberWindowFlags(key: String, flags: Int): Triple<AddFlagsFn, ClearFlagsFn, IsFlagsAdded>
Link copied to clipboard
operator fun <T> MutableRef<T>.setValue(thisObj: Any?, property: KProperty<*>, value: T)
Link copied to clipboard
infix fun <A, B, C, D, E> Tuple4<A, B, C, D>.to(e: E): Tuple5<A, B, C, D, E>
infix fun <A, B, C, D, E, F> Tuple5<A, B, C, D, E>.to(f: F): Tuple6<A, B, C, D, E, F>
infix fun <A, B, C, D, E, F, G> Tuple6<A, B, C, D, E, F>.to(g: G): Tuple7<A, B, C, D, E, F, G>
infix fun <A, B, C, D, E, F, G, H> Tuple7<A, B, C, D, E, F, G>.to(h: H): Tuple8<A, B, C, D, E, F, G, H>
infix fun <A, B, C, D, E, F, G, H, I> Tuple8<A, B, C, D, E, F, G, H>.to(i: I): Tuple9<A, B, C, D, E, F, G, H, I>
infix fun <A, B, C, D, E, F, G, H, I, J> Tuple9<A, B, C, D, E, F, G, H, I>.to(j: J): Tuple10<A, B, C, D, E, F, G, H, I, J>
infix fun <A, B, C> Pair<A, B>.to(c: C): Triple<A, B, C>
infix fun <A, B, C, D> Triple<A, B, C>.to(d: D): Tuple4<A, B, C, D>

infix fun <A, B> Single<A>.to(b: B): Pair<A, B>

元组扩展,可以使用 a to b to c 这样的连续中缀函数创建更多元素的元组

Link copied to clipboard
fun <T> Tuple10<T, T, T, T, T, T, T, T, T, T>.toList(): List<T>
fun <T> Tuple4<T, T, T, T>.toList(): List<T>
fun <T> Tuple5<T, T, T, T, T>.toList(): List<T>
fun <T> Tuple6<T, T, T, T, T, T>.toList(): List<T>
fun <T> Tuple7<T, T, T, T, T, T, T>.toList(): List<T>
fun <T> Tuple8<T, T, T, T, T, T, T, T>.toList(): List<T>
fun <T> Tuple9<T, T, T, T, T, T, T, T, T>.toList(): List<T>
fun <T> None.toList(): List<T>
fun <T> Single<T>.toList(): List<T>
Link copied to clipboard
fun tuple(): None
fun <A> tuple(first: A): Tuple1<A>
fun <A, B> tuple(first: A, second: B): Tuple2<A, B>
fun <A, B, C> tuple(first: A, second: B, third: C): Tuple3<A, B, C>
fun <A, B, C, D> tuple(first: A, second: B, third: C, fourth: D): Tuple4<A, B, C, D>
fun <A, B, C, D, E> tuple(first: A, second: B, third: C, fourth: D, fifth: E): Tuple5<A, B, C, D, E>
fun <A, B, C, D, E, F> tuple(first: A, second: B, third: C, fourth: D, fifth: E, sixth: F): Tuple6<A, B, C, D, E, F>
fun <A, B, C, D, E, F, G> tuple(first: A, second: B, third: C, fourth: D, fifth: E, sixth: F, seventh: G): Tuple7<A, B, C, D, E, F, G>
fun <A, B, C, D, E, F, G, H> tuple(first: A, second: B, third: C, fourth: D, fifth: E, sixth: F, seventh: G, eighth: H): Tuple8<A, B, C, D, E, F, G, H>
fun <A, B, C, D, E, F, G, H, I> tuple(first: A, second: B, third: C, fourth: D, fifth: E, sixth: F, seventh: G, eighth: H, ninth: I): Tuple9<A, B, C, D, E, F, G, H, I>
fun <A, B, C, D, E, F, G, H, I, J> tuple(first: A, second: B, third: C, fourth: D, fifth: E, sixth: F, seventh: G, eighth: H, ninth: I, tenth: J): Tuple10<A, B, C, D, E, F, G, H, I, J>
Link copied to clipboard
fun useAsync(): AsyncRunFn

This is a hook function that simplifies the use of coroutine scope. It's usage similar to the run function. Equivalent to scope.launch { }

fun useAsync(fn: SuspendAsyncFn): () -> Unit

This hook function accepts a suspend function as a parameter and returns a function(use to execute suspend function). When you call the execution function, the suspend function will be executed within the coroutine scope of the current component.

Link copied to clipboard
fun <T> useAutoReset(default: T & Any, interval: Duration): MutableState<T & Any>
Link copied to clipboard
fun useBackToFrontEffect(vararg deps: Any?, effect: () -> Unit)

Description: 进入后台再次回到前台时执行Effect,不同于官方 API,只在再进入时才执行。 第一次渲染(不执行)-> 进入后台在返回(执行)。

Link copied to clipboard
fun useBiometric(optionsOf: BiometricOptions.() -> Unit = {}): Pair<() -> Unit, State<Boolean>>
Link copied to clipboard
fun useBoolean(default: Boolean = false): BooleanHolder
Link copied to clipboard

快捷的使用剪切板:复制、粘贴

Link copied to clipboard

A React-ish hook that returns the current value for that context.

Link copied to clipboard
Link copied to clipboard
fun useCounter(initialValue: Int = 0, optionsOf: CounterOptions.() -> Unit): CounterHolder
Link copied to clipboard
fun <T> useCreation(vararg keys: Any?, factory: () -> T): Ref<T>

Description: useCreationuseRef 的替代品 。而相比于 useRef,你可以使用 useCreation 创建一些常量, 这些常量和 useRef 创建出来的 ref 有很多使用场景上的相似, 但对于复杂常量的创建,useRef 却容易出现潜在的性能隐患。

Link copied to clipboard
fun <S> useDebounce(value: S, optionsOf: DebounceOptions.() -> Unit = {}): State<S>
Link copied to clipboard
fun useDebounceEffect(vararg keys: Any?, optionsOf: DebounceOptions.() -> Unit = {}, block: SuspendAsyncFn)
Link copied to clipboard
fun useDebounceFn(fn: VoidFunction, optionsOf: DebounceOptions.() -> Unit = {}): VoidFunction
Link copied to clipboard
fun useDisableScreenshot(): Triple<DisableFn, EnableFn, IsDisabled>
Link copied to clipboard
Link copied to clipboard
fun useEffect(vararg deps: Any?, block: SuspendAsyncFn)

执行副作用的hook,通过设置deps依赖,可以在依赖发生变化时触发副作用闭包block的执行。 依赖性会先执行unwrap进行解包装,所以它可以监听 StateRef 这两种包装类。

Link copied to clipboard
inline fun <T : Any> useEventPublish(): (T) -> Unit

This hook returns a publish function, use that fun to post a event.

Link copied to clipboard
inline fun <T : Any> useEventSubscribe(noinline subscriber: (T) -> Unit)

Register a subscriber. Note that this subscription function will be removed from the subscription list after the component is uninstalled.

Link copied to clipboard
fun useFlashlight(): Pair<TurnOnFn, TurnOffFn>
Link copied to clipboard
Link copied to clipboard
fun useFrontToBackEffect(vararg deps: Any?, effect: () -> Unit)

Use front to back effect,contrary to the useBackToFrontEffect behavior, the effect is executed when the App enters the background

Link copied to clipboard
fun <T> useGetState(default: T & Any): GetStateHolder<T & Any>

Description: Using destructuring declarations on useState can cause closure problems. Using useLatestRef is a solution, but if you call the set function quickly(millisecond level), there will be a problem of state loss.

Link copied to clipboard
fun <T> useImmutableList(vararg elements: T): ImmutableListHolder<T>

这个 hook 不同于 useList

Link copied to clipboard
Link copied to clipboard
fun useInterval(optionsOf: IntervalOptions.() -> Unit = {}, block: () -> Unit): IntervalHolder
fun useInterval(optionsOf: IntervalOptions.() -> Unit = {}, ready: Boolean, block: () -> Unit)
Link copied to clipboard
Link copied to clipboard
fun <T> useLatestRef(value: T): Ref<T>
Link copied to clipboard

Description: Alias for rememberUpdatedState

Link copied to clipboard
fun <T> useList(vararg elements: T): SnapshotStateList<T>
Link copied to clipboard
Link copied to clipboard
fun <K, V> useMap(vararg pairs: Pair<K, V>): SnapshotStateMap<K, V>
Link copied to clipboard
fun useMount(fn: SuspendAsyncFn)
Link copied to clipboard
fun useNow(optionsOf: UseNowOptions.() -> Unit = {}): State<String>
Link copied to clipboard
fun <T> usePersistent(key: String, defaultValue: T, forceUseMemory: Boolean = false): PersistentHolder<T>

Use persistent

Link copied to clipboard
fun <T> usePrevious(present: T): State<T?>
Link copied to clipboard
fun <S, A> useReducer(reducer: Reducer<S, A>, initialState: S, middlewares: Array<Middleware<S, A>> = emptyArray()): ReducerHolder<S, A>
Link copied to clipboard
fun <T> useRef(default: T): MutableRef<T>
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun useSensor(sensorType: Int, onAccuracyChangedFn: (Sensor, Int) -> Unit = { _, _ -> }, onSensorChangedFn: (SensorEvent) -> Unit = { _ -> })
Link copied to clipboard
fun <T> useState(default: T & Any): MutableState<T & Any>

Description: 在compose中使用state需要写一点模板代码,虽然谈不上有多麻烦,但是还是能简化一下的; 返回值是MutableState,可以解构后使用。如果是可空对象需要显示声明:

fun <T> useState(vararg keys: Any?, factory: () -> T): State<T>

用于方便的创建派生状态,派生状态不同于普通的MutableState,他是一个只读的状态, 它只会在依赖发生变化时重新计算改变状态,在其他的框架中也称之为计算属性或者计算状态。

Link copied to clipboard
fun <S> useThrottle(value: S, optionsOf: ThrottleOptions.() -> Unit = {}): State<S>
Link copied to clipboard
fun useThrottleEffect(vararg keys: Any?, optionsOf: ThrottleOptions.() -> Unit = {}, block: SuspendAsyncFn)
Link copied to clipboard
fun useThrottleFn(fn: VoidFunction, optionsOf: ThrottleOptions.() -> Unit = {}): VoidFunction
Link copied to clipboard
fun useTimeout(delay: Duration = 1.seconds, block: () -> Unit)
Link copied to clipboard
fun useTimestamp(optionsOf: TimestampOptions.() -> Unit = {}, autoResume: Boolean = true): TimestampHolder
Link copied to clipboard
fun useTimestampRef(optionsOf: TimestampOptions.() -> Unit = {}, autoResume: Boolean = true): TimestampRefHolder
Link copied to clipboard
fun <T> useToggle(defaultValue: T? = null, reverseValue: T? = null): Pair<T?, ToggleFn>

用于在两个状态值间切换的 Hook。

Link copied to clipboard
fun <L, R> useToggleEither(defaultValue: L? = null, reverseValue: R? = null): Pair<Either<L?, R?>, ToggleFn>

Description:用于在两个状态值间切换的 Hook。为了保证类型信息不消失,使用Either作为容器保存; 调用者在使用时根据实际情况调用 Either.fold 函数或者其他函数处理;

Link copied to clipboard
fun useToggleVisible(isVisible: Boolean = false, content: ComposeComponent): Pair<ComposeComponent, ToggleFn>

用于方便的切换控制组件的可见性

fun useToggleVisible(isFirst: Boolean = true, content1: ComposeComponent, content2: ComposeComponent): Pair<ComposeComponent, ToggleFn>
Link copied to clipboard
fun <T> useUndo(initialPresent: T): UndoHolder<T>
Link copied to clipboard
fun useUnmount(block: () -> Unit)
Link copied to clipboard
Link copied to clipboard
inline fun useUpdate(): () -> Unit
Link copied to clipboard
fun useUpdateEffect(vararg deps: Any?, block: SuspendAsyncFn)
Link copied to clipboard
fun useWakeLock(): Triple<RequestFn, ReleaseFn, IsActive>
Link copied to clipboard
fun useWindowFlags(key: String, flags: Int): Triple<AddFlagsFn, ClearFlagsFn, IsFlagsAdded>