Using Firebase, after I fetch and activate my remote config values, calling configValue(forKey key: String?) will give me the value from the remote source. I know I can call func configValue(forKey key: String?, source: RemoteConfigSource) or defaultValue(forKey key: String?) to get the default value. But, how do I reset my activated data so that calling configValue will give me the default values again?
Further, do the activated values persisted ever get purged?
Firebaser here with some additional info that could be helpful.
The Android SDK does have a reset method as of the v2 release that can do what you're looking for here. The reset() call will reset Remote Config to the state when it was first installed, and then you can call setDefaults() to reset to the default values and continue using them. From that point if you want to keep using these default values, you would want to avoid calling activate and fetch. Once you make those calls, the default values may get updated at the initial fetch call or following fetch intervals.
Also, the reset() isn't available in the iOS v2 SDK today, but it sounds like a reasonable request. Could you please file a feature request if this feature would be helpful for you?
Related
How to add a pre-draw hook to current context workspace.tools change?
I attempted to get there using bpy.types.SpaceView3D.draw_handler_add(...) which as it runs on every draw, checks if workspace.tools changed, and if it changed, run my callback, but my callback wants to add its own SpaceView3D.draw_handler_add and doing it this way adds it a frame-too-late, leaving the view port undrawn until a user event repaints the screen.
I found this post online
https://devtalk.blender.org/t/update-property-when-active-tool-changes/11467/12
summary: maybe there is a mainline callback new
https://developer.blender.org/D10635
AFWS Jan '20
#kaio
This seem like a better solution. It’s kind of a mystery code, cause I
couldn’t figure out where you got that code info ,but then started
looking at the space_toolsystem_common.py file. kaio AFWS Jan '20
Just realized there might be a cleaner way of getting callbacks for
active tools using the msgbus. Since workspace tools aren’t rna
properties themselves, figured it’s possible to monitor the
bpy_prop_collection which changes with the tool.
The handle is the workspace itself, so shouldn’t have to worry about
keeping a reference. The subscription lasts until a new file is
loaded, so add a load_post callback which reapplies it.
Note this doesn’t proactively subscribe to workspaces added
afterwards. Might need a separate callback for that :joy:
import bpy
def rna_callback(workspace):
idname = workspace.tools[-1].idname
print(idname)
def subscribe(workspace):
bpy.msgbus.subscribe_rna(
key=ws.path_resolve("tools", False),
owner=workspace,
args=(workspace,),
notify=rna_callback)
if __name__ == "__main__":
ws = bpy.context.workspace
subscribe(bpy.context.workspace)
# Subscribe to all workspaces: if 0:
for ws in bpy.data.workspaces:
subscribe(bpy.context.workspace)
# Clear all workspace subscriptions if 0:
for ws in bpy.data.workspaces:
bpy.msgbus.clear_by_owner(ws)
I would like to access a Web Audio Node's calculated output or param value at the current time (after any connected node's contributions have been added) in the main thread.
Currently all I can access is the value set using the AudioParam methods or the setter of AudioParam.value, but the contributions from any other nodes that I connect are not applied when using the AudioParam.value getter. Is this 1) intentional and 2) are there any workarounds to get the actual value in the main thread that a AudioWorkletProcessor would receive (which would sum the values from each input and add that to the value)?
You could use a ConstantSourceNode with appropriate automations of the offset AudioParam. Then connect some signal to the offset and finally look at the output of the node to see the computed value. You still need to use an AnalyserNode, ScriptProcessorNode, or AudioWorkletNode to get at the output values.
This isn't a perfect solution.
Is there any strategy for having you code run only once(like initState()) and have the context also available (to use .of(context)). For example I am getting Bloc.of(context) and I want to subscribe to it (do some stuff like showing an alert dialog, etc). Subscribing in build(), means subscribing multiple times
I can use didChangeDependencies() and set the subscription ??= bloc.listen, but I was wondering if there is another good strategy.
there is another way to do that , by add a "bool" variable and set it as "false" in the "initState" , and lets named (isExec)
2 - in the build method check if "isExec" == false , then run your code that you want to excute it once (alert , subscribe .. etc)
3 - change "isExec" to true (isExec = true);
now if your app state change the build method well avoid that code in the if statment
First of all, let me say that this is NOT a complaint, I just want to understand how does the register(defaults: []) method works.
I'm using the UserDefaults register(defaults: []) method inside the didFinishLaunchingWithOptions method to register the default value of all of my UseDefault keys, everything is working fine as expected.
My question is, why is that the values in the register(defaults: []) method do not reset everytime the didFinishLaunchingWithOptions method is called?
I do not want them to rest I'm just trying to understand why.
I have the following code...
func application(...didFinishLaunchingWithOptions...) -> Bool {
UserDefaults.standard.register(defaults: [
keyUserName:"",
keyHasCar:false
])
}
Here is why my confusion, when the app runs, it saves the default values as expected, then, if the values get modified later somewhere in the app and right-after the app is killed and relaunched, the didFinishLaunchingWithOptions is called again but the values do not get reset, but if I add a new key to the array it does get saved but the rest of the keys do not get reset only the new one is added with its default value.
Again, I do not want the values to reset, I just need to understand how does register method works.
From the documentation for register(defaults:):
If there is no registration domain, one is created using the specified dictionary, and NSRegistrationDomain is added to the end of the search list.
The contents of the registration domain are not written to disk; you need to call this method each time your application starts.
What this means is that the registered defaults act as a fallback to the normal, user defaults that you are working with. The registered defaults do not overwrite or replace the standard user defaults.
When you attempt to lookup a key from UserDefaults.standard, if the key isn't there, then it is looked up in the registered defaults and that result (if any) is returned.
Once you set a value in UserDefaults.standard, of course it is that value that is returned for the key. If you remove the key from UserDefaults.standard then the registered default is used again.
In my app I use CloudKit and a user's private CKDatabase to store records. I do fetches for changes when the app starts as it adviced at WWDC 2016.
Firstly, I call the fetchDatabaseChanges(database: CKDatabase, databaseTokenKey: String, completion: #escaping () -> Void) method.
Inside this method in changesOperation.fetchDatabaseChangesCompletionBlock I save a CKServerChangeToken to userDefaults for a key : ckDatabaseToken.
I also call the fetchZoneChanges(database: database, databaseTokenKey: databaseTokenKey, zoneIDs: changedZoneIDs, completion in the changesOperation.fetchDatabaseChangesCompletionBlock of the fetchDatabaseChanges method.
In the fetchZoneChanges method there is an operation.recordZoneFetchCompletionBlock. Inside this block we also need to save the value of the token to the UserDefaults. And I'm saving it to another ckZoneToken variable in User Defaults. So inside the fetchZoneChanges I get and save (from/to UserDefaults) the ckZoneToken value, and inside the fetchDatabaseChanges, I get and save (from/to UserDefaults) the ckDatabaseToken value .
Is it the right technique? Or it is better to use only the one variable in both fetchDatabaseChanges and fetchZoneChanges method sto store the value of CKServerChangeToken?
Which will be the best approach?
Swift 3, Xcode 9
I've experimented with both ways and figured out that if we use the one changeToken in user defaults, we get a "Bad sync continuation data" error.
When I've used 2 separate values to store database changes and zone changes, I have had no errors.
So, I think that we have to cache a CKServerChangeToken both in CKDatabase and CKRecordZone separately.