rex_firebase_counter
Plugin, ACE table, Discussion thread
Dependence: rex_firebase_apiV3
Dependence: rex_firebase_apiV3
Introduction
Counter to increase or decrease value.
Counter to increase or decrease value.
Usage
Concept
Counter could be accumulated by many users at the same time. The result of accumulation is calculated with transaction feature of firebase.
Counter could be accumulated by many users at the same time. The result of accumulation is calculated with transaction feature of firebase.
Get current counter value
Call "Action:Start" to start updating counter value automatically. "Condition:On update" will be triggered when received new counter value from firebase server. Then get counter value by "Expression:LastValue".
Call "Action:Stop" to stop auto updating. i.e. "Condition:On update" will not be triggered anymore.
Call "Action:Start" to start updating counter value automatically. "Condition:On update" will be triggered when received new counter value from firebase server. Then get counter value by "Expression:LastValue".
Call "Action:Stop" to stop auto updating. i.e. "Condition:On update" will not be triggered anymore.
Accumulating value
There are two methods to accumulate value into counter-
There are two methods to accumulate value into counter-
Add by value
Sample capx, sample capx-V3
Call "Action:Try add to" to add value to counter, the added value could be
Sample capx, sample capx-V3
Call "Action:Try add to" to add value to counter, the added value could be
positive number: 3
negative number: -1
string: "+10%", it is equal to (current counter value * 0.1)
"Condition:On my writing" will be triggered after value writing completely. Get wrote value of this writting access by "Expression:LastWroteValue", and added to value by "Expression:LastAddedValue".
Each counter value writing will trigger "Condition:On update", only counter value wrote by current client will trigger "Condition:On my writing".
Each counter value writing will trigger "Condition:On update", only counter value wrote by current client will trigger "Condition:On my writing".
Add by custom function
Sample capx, sample capx-V3
Call "Action:Try add by function" to get added value by function. i.e. by event "Condition:On custom add". In this "Condition:On custom add" event, return added value by "Action:Add to" under "Custom add" category. Or call "Action:Abort" to cancel this writing action. Get current counter value by "Expression:CustomAddIn" for calculating.
Sample capx, sample capx-V3
Call "Action:Try add by function" to get added value by function. i.e. by event "Condition:On custom add". In this "Condition:On custom add" event, return added value by "Action:Add to" under "Custom add" category. Or call "Action:Abort" to cancel this writing action. Get current counter value by "Expression:CustomAddIn" for calculating.
"Action:Try add by function" -> "Condition:On custom add" -> "Expression:CustomAddIn" -> "Action:Add to"
After value wrote, "Condition:On my writing" will be triggered, like previous section described.
Force set value
Call "Action:Force set to" to set counter value to specific value. It will cancel any pending value adding action.
Call "Action:Force set to" to set counter value to specific value. It will cancel any pending value adding action.
Initial value
Initial value of counter is set at "Initial" in properties table, which is a start value of accumulating. Or set this value by "Action:Set boundaries".
Initial value of counter is set at "Initial" in properties table, which is a start value of accumulating. Or set this value by "Action:Set boundaries".
Upper bound
The counter value will be clamped at "Upper bound" which set in properties table, or by "Action:Set boundaries".
The "Upper bound" could be less than "Initial" if this counter is a decremental counter. leave an empty string "" at this filed to ignore upper bound.
The writing of counter will be aborted after counter value had been clamped to upper bound. i.e. "Condition:On my writing abort" will be triggered.
The counter value will be clamped at "Upper bound" which set in properties table, or by "Action:Set boundaries".
The "Upper bound" could be less than "Initial" if this counter is a decremental counter. leave an empty string "" at this filed to ignore upper bound.
The writing of counter will be aborted after counter value had been clamped to upper bound. i.e. "Condition:On my writing abort" will be triggered.