HostService class
Lets the app register named host functions callable from journey JavaScript.
This must be a single long-lived instance (see DataSapien.getHostService):
its HostFunctionCallbackApi registration and handler map persist for the
lifetime of the app.
Note: call registerFunction (and the other methods) after
DataSapien.initialize(). On both iOS and Android the underlying native
HostService requires the SDK to be initialized first.
- Implemented types
Constructors
- HostService(HostServiceApi _api)
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
cancelAllFunctions(
{String reason = 'journey_cancelled'}) → Future< void> -
Reject all in-flight host-function calls with
reason. Typically called when the journey hosting the JS runtime is dismissed or cancelled. -
invokeHandler(
String callId, String name, String argsJson, List< String?> callbackNames) → void -
Native -> Dart entry point (from HostFunctionCallbackApi). Not part of
the public API; runs the registered handler and completes the JS promise.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
registerFunction(
String name, HostFunctionHandler handler) → Future< void> -
Register
handlerundernameso journey JavaScript can call it viaawait HostService.invokeFunction(name, args, callbacks). -
toString(
) → String -
A string representation of this object.
inherited
-
unregisterFunction(
String name) → Future< void> - Remove a previously registered function; no-op if it is not present.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited