rex_firebase
Introduction
Real time database-as-a-service - firebase.
Real time database-as-a-service - firebase.
Usage
My connection status
Sample capx , sample capx-V3
Set property "Connection detection" to "Yes" to enable connection status detection.
Sample capx , sample capx-V3
Set property "Connection detection" to "Yes" to enable connection status detection.
- "Condition:On connected" will be triggered while connecting started.
- "Condition:On disconnected" will be triggered while disconnected after connected.
- "Condition:Is connected" will return true if connected to server.
Saving data
Data in firebase is stored in JSON object (key-data). Each key is a reference in URL string.
Data in firebase is stored in JSON object (key-data). Each key is a reference in URL string.
Set data
Sample capx , sample capx-V3
Uses these actions to change the value at key reference
Sample capx , sample capx-V3
Uses these actions to change the value at key reference
- Action:Set value
- Action:Set _boolean value
- Action:Set JSON
Append data
Sample capx, sample capx-V3
Append value under the key reference by these actions
Sample capx, sample capx-V3
Append value under the key reference by these actions
- Action:Push value
- Action:Push boolean value
- Action:Push JSON
Transaction
Sample capx - fill domain URL to designer's firebase first
If designer want to change value according to current saved value, for example, increase counter. It needs to read-modify-write with this steps -
Sample capx - fill domain URL to designer's firebase first
If designer want to change value according to current saved value, for example, increase counter. It needs to read-modify-write with this steps -
- Call "Action:Transaction" to send a read request.
- "Condition:On transaction" will be triggered while read request successful. Get value by "Expression:TransactionIn" under this condition. Add default value at 1st parameter, this default value will be returned if no value in target key. Or check if the value is null by "Condition:TransactionIn is null".
- Write modified value with "Action:Set value" or "Action:Set JSON" in "Transaction" category under "Condition:On transaction". Writing will be aborted if no "Action:Set value" or "Action:Set JSON" had been called under this condition.
- "Condition:On complete" or "Condition:On error" under "Transaction - completed" category will be triggered if transaction successful or error happened. "Condition:TransactionIn aborted" will return true if this transaction had been aborted, i.e. no "Action:Set value" or "Action:Set JSON" had been called. Get wrote result by "Expression:TransactionResult".
Remove data
Remove data by
Remove data by
- Action:Remove
Sending-completed trigger
"Condition:On complete" will be triggered after any sending action.
"Condition:On error" will be triggered if sending was failed.
"Condition:On complete" will be triggered after any sending action.
"Condition:On error" will be triggered if sending was failed.
Retrieving data
Firebase data is retrieved by attaching an asynchronous listener at a key (i.e. reference). The listener will be triggered once for the initial state of the data and again anytime the data changes.
Firebase data is retrieved by attaching an asynchronous listener at a key (i.e. reference). The listener will be triggered once for the initial state of the data and again anytime the data changes.
Add a listener
Call "Action:Add callback" to register a listener with a specific callback name at the key reference. Each key reference could have more than one listener with different callback name.
Call "Action:Add callback" to register a listener with a specific callback name at the key reference. Each key reference could have more than one listener with different callback name.
Receive data
"Condition:On received" with a matched callback name will be triggered if any data received by this listener.
Get data by "Expression:LastData". Add default value at 1st parameter, this default value will be returned if no value in target key. Or check if the value is null by "Condition:LastData is null".
"Condition:On received" with a matched callback name will be triggered if any data received by this listener.
Get data by "Expression:LastData". Add default value at 1st parameter, this default value will be returned if no value in target key. Or check if the value is null by "Condition:LastData is null".
Remove the listener
Call "Action:Remove callback" to remove a listener with a specific callback name.
Or call "Action:Remove all callbacks at ref" to remove all listeners bound to this key reference.
Call "Action:Remove callback" to remove a listener with a specific callback name.
Or call "Action:Remove all callbacks at ref" to remove all listeners bound to this key reference.
Event types of listener
Each listener is one of these 4 event types -"Value changed", "Child added", "Child changed", "Child removed", "Child moved" for different saving data operations.
Each listener is one of these 4 event types -"Value changed", "Child added", "Child changed", "Child removed", "Child moved" for different saving data operations.
- "Action:Set value", "Action:Set JSON" will fire "Value changed". If this action overwrites a table to be a signal value, "Child removed" might be fire.
- "Action:Push value", "Action:Push JSON" will fire "Child added", and "Value changed".
- "Action:Remove" will fire "Value changed", or "Child removed" if a table had be removed.
Event Guarantees
Reference
Firebase makes several important guarantees regarding events:
Reference
Firebase makes several important guarantees regarding events:
- Events will always be triggered when local state changes.
- Events will always eventually reflect the correct state of the data, even in cases where local operations or timing cause temporary differences, such as in the temporary loss of network connection.
- Writes from a single client will always be written to the server and broadcast out to other users in-order.
- Value events are always triggered last and are guaranteed to contain updates from any other events which occurred before that snapshot was taken.
Retrieving data order in "Child added" event type
The received data under "Child added" event type might be out-of-order, since firebase is a real-time database. Designer could get all data in-order under "Value changed" event type, or maintain the order manually in client side.
The received data under "Child added" event type might be out-of-order, since firebase is a real-time database. Designer could get all data in-order under "Value changed" event type, or maintain the order manually in client side.
Presence
Sample capx, sample capx-V3
Sample capx, sample capx-V3
Actions while disconnection
Designer could register handlers for disconnection by these actions -
Designer could register handlers for disconnection by these actions -
- Action:Remove
- Action:Set value
- Action:Update JSON
Clock skew
Sample capx
Set property "Server time offset detection" to "Yes" to get server time offset ( transfer time between firebase server to current client ) continuously.
Get server time offset by "Expression:ServerTimeOffset", or get estimated the server time by "Expression:EstimatedTime", which is equal to ( current client time + server time offset ).
Sample capx
Set property "Server time offset detection" to "Yes" to get server time offset ( transfer time between firebase server to current client ) continuously.
Get server time offset by "Expression:ServerTimeOffset", or get estimated the server time by "Expression:EstimatedTime", which is equal to ( current client time + server time offset ).
Run at mobile app
The plugins are compatible with Cordova(Phonegap) for mobile apps.
The plugins are compatible with Cordova(Phonegap) for mobile apps.