Functions
The following functions are available globally.
-
withTimeout(seconds:Asynchronousbody: ) Execute an operation in the current task subject to a timeout.
Throws
ThrowsTimedOutErrorif the timeout expires beforeoperationcompletes. Ifoperationthrows an error before the timeout expires, that error is propagated to the caller.Declaration
Swift
public func withTimeout<T: Sendable>( seconds: TimeInterval, body: @escaping @Sendable () async throws -> T ) async throws -> TParameters
secondsThe duration in seconds
operationis allowed to run before timing out.operationThe async operation to perform.
Return Value
Returns the result of
operationif it completed in time. -
Undocumented
Declaration
Swift
public func curry<A, B, C>(_ f: @escaping (A, B) -> C) -> (A) -> (B) -> C -
Undocumented
Declaration
Swift
public func curry<A, B, C>(_ f: @escaping (A, B) throws -> C) -> (A) -> (B) throws -> C -
Undocumented
Declaration
Swift
public func curry<A, B, C>(_ f: @escaping (A, B) async throws -> C) -> (A) -> (B) async throws -> C -
Undocumented
Declaration
Swift
public func curryFirst<A, B>(_ f: @escaping (A) -> B) -> (A) -> () -> B -
Undocumented
Declaration
Swift
public func curryFirst<A, B>(_ f: @escaping (A) async throws -> B) -> (A) -> () async throws -> B -
Undocumented
Declaration
Swift
public func curryFirst<A, B, C>(_ f: @escaping (A, B) -> C) -> (A) -> (B) -> C -
Undocumented
Declaration
Swift
public func curryFirst<A, B, C>(_ f: @escaping (A, B) async throws -> C) -> (A) -> (B) async throws -> C -
Undocumented
Declaration
Swift
public func curryFirst<A, B, C, D>(_ f: @escaping (A, B, C) -> D) -> (A) -> (B, C) -> D -
Undocumented
Declaration
Swift
public func curryFirst<A, B, C, D>(_ f: @escaping (A, B, C) async throws -> D) -> (A) -> (B, C) async throws -> D
-
An atom represents state in Recoil. The
atom()function returns a writeableRecoilStateobject.Declaration
Swift
public func atom<T: Equatable>(_ value: T, funcName: String = #function, fileID: String = #fileID, line: Int = #line) -> Atom<T>Return Value
A writeable RecoilState object.
-
An atom represents state in Recoil. The
atom()function returns a writeableRecoilStateobject.Declaration
Swift
public func atom<T: Equatable>(_ fn: @escaping () -> T, funcName: String = #function, fileID: String = #fileID, line: Int = #line) -> Atom<T>Return Value
A writeable RecoilState object.
-
An atom represents state in Recoil. The
atom()function returns a writeableRecoilStateobject.Declaration
Swift
public func atom<T: Equatable, E: Error>(_ fn: @escaping AtomCombineGet<T, E>, funcName: String = #function, fileID: String = #fileID, line: Int = #line) -> AsyncAtom<T>Return Value
A writeable RecoilState object.
-
An atom represents state in Recoil. The
atom()function returns a writeableRecoilStateobject.Declaration
Swift
public func atom<T: Equatable>(_ fn: @escaping AtomAsyncGet<T>, funcName: String = #function, fileID: String = #fileID, line: Int = #line) -> AsyncAtom<T>Return Value
A writeable RecoilState object.
-
A
atomFamilyis a powerful pattern that is similar to a atom, but allows you to pass parametersDeclaration
Swift
public func atomFamily<P: Hashable, T: Equatable>( _ getBody: @escaping AtomFamilyGet<P, T>, funcName: String = #function, fileID: String = #fileID, line: Int = #line ) -> AtomFamily<P, T>Parameters
getBodyA function that is passed an object of named callbacks that returns the value of the atom
Return Value
A function which can be called with user-defined parameters and returns a selector. Each unique parameter value will return the same memoized selector instance.
-
A
atomFamilyis a powerful pattern that is similar to a atom, but allows you to pass parametersDeclaration
Swift
public func atomFamily<P: Hashable, T: Equatable, E: Error>( _ getBody: @escaping AtomFamilyCombineGet<P, T, E>, funcName: String = #function, fileID: String = #fileID, line: Int = #line ) -> AsyncAtomFamily<P, T>Parameters
getBodyA function that can pass an user-defined parameter.
Return Value
A function which can be called with user-defined parameters and returns a asynchronous atom with combine. Each unique parameter value will return the same memoized atom instance.
-
A
atomFamilyis a powerful pattern that is similar to a atom, but allows you to pass parametersDeclaration
Swift
public func atomFamily<P: Hashable, T: Equatable>( _ getBody: @escaping AtomFamilyAsyncGet<P, T>, funcName: String = #function, fileID: String = #fileID, line: Int = #line ) -> AsyncAtomFamily<P, T>Parameters
getBodyA function that can pass an user-defined parameter.
Return Value
A function which can be called with user-defined parameters and returns a asynchronous atom with
async/await. Each unique parameter value will return the same memoized atom instance. -
A
selectorFamilyis a powerful pattern that is similar to a selector, but allows you to pass parametersDeclaration
Swift
public func selectorFamily<P: Hashable, T: Equatable>( _ getBody: @escaping SelectorFamilyGet<P, T>, funcName: String = #function, fileID: String = #fileID, line: Int = #line ) -> SelectorFamily<P, T>Parameters
getBodyA function that is passed an object of named callbacks that returns the value of the selector
Return Value
A function which can be called with user-defined parameters and returns a selector. Each unique parameter value will return the same memoized selector instance.
-
A
selectorFamilyis a powerful pattern that is similar to a selector, but allows you to pass parametersDeclaration
Swift
public func selectorFamily<P: Hashable, T: Equatable, E: Error>( _ getBody: @escaping SelectorFamilyCombineGet<P, T, E>, funcName: String = #function, fileID: String = #fileID, line: Int = #line ) -> AsyncSelectorFamily<P, T>Parameters
getBodyA function that can pass an user-defined parameter. and it evaluates the value for the derived state.
Return Value
A function which can be called with user-defined parameters and returns a asynchronous selector with combine. Each unique parameter value will return the same memoized selector instance.
-
A
selectorFamilyis a powerful pattern that is similar to a selector, but allows you to pass parametersDeclaration
Swift
public func selectorFamily<P: Hashable, T: Equatable>( _ getBody: @escaping SelectorFamilyAsyncGet<P, T>, funcName: String = #function, fileID: String = #fileID, line: Int = #line ) -> AsyncSelectorFamily<P, T>Parameters
getBodyA function that can pass an user-defined parameter. and it evaluates the value for the derived state.
Return Value
A function which can be called with user-defined parameters and returns a asynchronous selector with
async/await. Each unique parameter value will return the same memoized selector instance.
-
A Selector represent a derived state in Recoil. If only a get function is provided, the selector is read-only and returns a
Readonly SelectorDeclaration
Return Value
A synchronous readonly selector.
-
A Selector represent a derived state in Recoil. If only a get function is provided, the selector is read-only and returns a
Readonly SelectorDeclaration
Swift
public func selector<T: Equatable, E: Error>(_ getBody: @escaping CombineGet<T, E>, funcName: String = #function, fileID: String = #fileID, line: Int = #line) -> AsyncSelector<T>Return Value
A asynchronous readonly selector with combine.
-
A Selector represent a derived state in Recoil. If only a get function is provided, the selector is read-only and returns a
Readonly SelectorDeclaration
Swift
public func selector<T: Equatable>(_ getBody: @escaping AsyncGet<T>, funcName: String = #function, fileID: String = #fileID, line: Int = #line) -> AsyncSelector<T>Return Value
A asynchronous readonly selector with
async/await. -
A Selector represent a derived state in Recoil. If the get and set function are provided, the selector is writeable
Declaration
Swift
public func selector<T: Equatable>(get getBody: @escaping SyncGet<T>, set setBody: @escaping SetBody<T>, funcName: String = #function, fileID: String = #fileID, line: Int = #line) -> MutableSelector<T>Return Value
A asynchronous readonly selector with
async/await. -
A hook provide an API for your callbacks to work with Recoil state. Diffrent with other hooks, the hook don’t load state, until you manually call it. Asynchronously read Recoil state without subscribing a component to re-render if the atom or selector is updated.
Declaration
Swift
@MainActor public func useRecoilCallback<Return>(_ fn: @escaping Callback<Return>) -> () -> ReturnParameters
fnA function that you want to access the Recoil state
Return Value
return a callback function that can trigger state update after call it
-
Undocumented
Declaration
Swift
@MainActor public func useRecoilCallback<Return>(_ fn: @escaping AsyncCallback<Return>) -> () async throws -> Return -
A hook provide an API for your callbacks to work with Recoil state. Diffrent with other hooks, the hook don’t load state, until you manually call it. Asynchronously read Recoil state without subscribing a component to re-render if the atom or selector is updated.
Declaration
Swift
@MainActor public func useRecoilCallback<P, R>(_ fn: @escaping Callback1<P, R>) -> (P) -> RParameters
fnA function that you want to access the Recoil state with one user-defined parameter
Return Value
return a callback function that can trigger state update after call it
-
Undocumented
Declaration
Swift
@MainActor public func useRecoilCallback<P, R>(_ fn: @escaping AsyncCallback1<P, R>) -> (P) async throws -> R -
A hook provide an API for your callbacks to work with Recoil state. Diffrent with other hooks, the hook don’t load state, until you manually call it. Asynchronously read Recoil state without subscribing a component to re-render if the atom or selector is updated.
Declaration
Swift
@MainActor public func useRecoilCallback<P1, P2, R>(_ fn: @escaping Callback2<P1, P2, R>) -> (P1, P2) -> RParameters
fnA function that you want to access the Recoil state with two user-defined parameters
Return Value
return a callback function that can trigger state update after call it
-
Undocumented
Declaration
Swift
@MainActor public func useRecoilCallback<P1, P2, R>(_ fn: @escaping AsyncCallback2<P1, P2, R>) -> (P1, P2) async throws -> R -
A hook will subscribe the component to re-render if there are changing in the Recoil state.
Declaration
Swift
@MainActor public func useRecoilValue<P: Equatable, Return: RecoilSyncNode>( _ value: RecoilParamNode<P, Return> ) -> Return.T?Parameters
valueSelectors which with user-defined parameters
Return Value
return a readable inner value that wrapped in recoil state. if the state is async state, it return will
'value?', otherwise it return'value' -
Undocumented
Declaration
Swift
@MainActor public func useRecoilValue<P: Equatable, Return: RecoilAsyncNode>( _ value: RecoilParamNode<P, Return> ) -> Return.T? -
A hook will subscribe the component to re-render if there are changing in the Recoil state.
Declaration
Swift
@MainActor public func useRecoilValue<Value>(_ initialState: Value) -> Value.T? where Value : RecoilSyncNodeParameters
valuea recoil state (
atomorselector)Return Value
return a readable inner value that wrapped in recoil state. if the state is async state, it return will
'value?', otherwise it return'value' -
Undocumented
Declaration
Swift
@MainActor public func useRecoilValue<Value>(_ initialState: Value) -> Value.T? where Value : RecoilAsyncNode -
A hook will subscribe the component to re-render if there are changing in the Recoil state.
Declaration
Swift
@MainActor public func useRecoilState<P: Equatable, Return: RecoilMutableSyncNode>( _ value: RecoilParamNode<P, Return> ) -> Binding<Return.T>Parameters
initialStatea writeable recoil state wrapper which with a
recoil stateanduser-defined parametersReturn Value
return a
Bindingvalue that wrapped in recoil state. if the state is async state, it return will'Binding<value?>', otherwise it return'Binding<value>' -
A hook will subscribe the component to re-render if there are changing in the Recoil state.
Declaration
Swift
@MainActor public func useRecoilState<Value>(_ initialState: Value) -> Binding<Value.T> where Value : RecoilSyncNode, Value : WriteableParameters
initialStatea writeable recoil state(
atomor writeableselector)Return Value
return a
Bindingvalue that wrapped in recoil state. if the state is async state, it return will'Binding<value?>', otherwise it return'Binding<value>' -
A hook is intended to be used for reading the value of asynchronous selectors. eg: You can get the
loading,errorstatus with this hooksDeclaration
Swift
@MainActor public func useRecoilValueLoadable<P: Equatable, Return: RecoilNode>( _ value: RecoilParamNode<P, Return> ) -> LoadableContent<Return.T>Parameters
valueA selector wrapper which with user-defined parameters
Return Value
return a loadable object that contains loading informations
-
A hook is intended to be used for reading the value of asynchronous selectors. eg: You can get the
loading,errorstatus with this hooksDeclaration
Swift
@MainActor public func useRecoilValueLoadable<Value>(_ value: Value) -> LoadableContent<Value.T> where Value : RecoilNodeParameters
valueA selector
Return Value
return a loadable object that contains loading informations
Functions Reference