FunctionDeclarations
Declares, in a native module's spec, on which thread each of its functions runs.
Usage
Connect a reporting service
This type is used by fn
// modules/crash-service/crash-service.ts
import { defineModule, fn } from 'kuito';
export default defineModule('CrashService', {
start: fn.main<(key: string) => Promise<void>>(),
ios: { class: 'CrashServiceModule' },
android: { class: 'com.example.myapp.modules.crashservice.CrashServiceModule' },
});Type declaration
export interface FunctionDeclarations {
/** Runs on the JS thread and returns its value. Keep it fast, thread-safe and off UIKit and Views. */
sync<F extends SyncFunction>(): Synchronous<F>;
/** Runs on the main (UI) thread. */
main: QueuedDeclaration;
/** Runs on the module's own serial background thread, in call order. */
background: QueuedDeclaration;
}Members 3
| Name | Type | Required | Description |
|---|---|---|---|
sync | <F extends SyncFunction>() => Synchronous<F> | Yes | Runs on the JS thread and returns its value. Keep it fast, thread-safe and off UIKit and Views. |
main | QueuedDeclaration | Yes | Runs on the main (UI) thread. |
background | QueuedDeclaration | Yes | Runs on the module's own serial background thread, in call order. |
sync — method signatures
Signatures
<F extends SyncFunction>(): Synchronous<F>Type parameters
| Name | Constraint | Default |
|---|---|---|
F | SyncFunction | — |
Parameters
No parameters.
Returns
Synchronous<F>
main — method signatures
Signatures
<F extends AsyncFunction>(): FType parameters
| Name | Constraint | Default |
|---|---|---|
F | AsyncFunction | — |
Parameters
No parameters.
Returns
F
background — method signatures
Signatures
<F extends AsyncFunction>(): FType parameters
| Name | Constraint | Default |
|---|---|---|
F | AsyncFunction | — |
Parameters
No parameters.
Returns
F
Generated from the public TypeScript declarations: signatures, props and defaults come from the checked source, descriptions from its JSDoc. No defaults are invented.