Interface Status.DataUpdateStatusProvider
- Enclosing class:
- Status
DataSynchronizer
With the build-in implementation, this might be useful if you want to use SDK without waiting for it to initialize-
Method Summary
Modifier and TypeMethodDescriptiongetState()Returns the current status of theDataSynchronizerbooleanwaitFor(Status.StateType state, Duration timeout) A method for waiting for a desired connection state after bootstrappingbooleanwaitForOKState(Duration timeout) alias ofwaitFor(StateType, Duration)inStatus.StateType.OK
-
Method Details
-
getState
Status.State getState()Returns the current status of theDataSynchronizerAll of the
DataSynchronizerimplementations are guaranteed to update this status whenever they successfully initialize, encounter an error, or recover after an error.For a custom implementation, it is the responsibility of the data source to report its status via
Status.DataUpdater; if it does not do so, the status will always be reported asStatus.StateType.INITIALIZING.- Returns:
- the latest status; will never be null
-
waitFor
A method for waiting for a desired connection state after bootstrappingIf the current state is already
desiredStatewhen this method is called, it immediately returns. Otherwise, it blocks until 1. the state has becomedesiredState, 2. the state has becomeStatus.StateType.OFF, 3. the specified timeout elapses, or 4. the current thread is deliberately interrupted withThread.interrupt().A scenario in which this might be useful is if you want to use SDK without waiting for it to initialize, and then wait for initialization at a later time or on a different point:
FBConfig config = new FBConfig.Builder() .startWait(Duration.ZERO) .build(); FBClient client = new FBClient(sdkKey, config); // later, when you want to wait for initialization to finish: boolean inited = client.getDataUpdateStatusProvider().waitFor(StateType.OK, Duration.ofSeconds(15)) if (!inited) { // do whatever is appropriate if initialization has timed out }- Parameters:
state- the desired connection state (normally this would beStatus.StateType.OK)timeout- the maximum amount of time to wait-- orDuration.ZEROto block indefinitely (unless the thread is explicitly interrupted)- Returns:
- true if the connection is now in the desired state; false if it timed out, or if the state changed to 2 and that was not the desired state
- Throws:
InterruptedException- ifThread.interrupt()was called on this thread while blocked
-
waitForOKState
alias ofwaitFor(StateType, Duration)inStatus.StateType.OK- Parameters:
timeout- the maximum amount of time to wait-- orDuration.ZEROto block indefinitely (unless the thread is explicitly interrupted)- Returns:
- true if the connection is now in
Status.StateType.OK; false if it timed out, or if the state changed toStatus.StateType.OFFand that was not the desired state - Throws:
InterruptedException- throws an InterruptedException
-