Difference between revisions of "Bot Playground/Built-in Functions/localStorage.on"

From SmartBots Developers Docs
Jump to: navigation, search
(Created page with "{{DISPLAYTITLE:{{SUBPAGENAME}}}} <onlyinclude>Adds the event callback on localStorage.</onlyinclude> Also check Bot_Playground/Built-in_Functions/localStorage.set|localStora...")
 
Line 19: Line 19:
 
Use this function if you want to know when other scripts do localStorage.set().
 
Use this function if you want to know when other scripts do localStorage.set().
  
Important: the "update" event ''does not'' react on localStorage.set() in current script.
+
Important: the "update" event ''does not'' react on localStorage.set() calls in current script.
  
 
== Example ==
 
== Example ==

Revision as of 21:49, 14 July 2018

Adds the event callback on localStorage. Also check localStorage.set().

localStorage.on(eventName, callback);

Reference

This command accepts the following parameters:

Variable Required Description


Input:
eventName yes the name of the event. Currently only supported event is "update"
callback yes the callback function to fire on event

Comments

Use this function if you want to know when other scripts do localStorage.set().

Important: the "update" event does not react on localStorage.set() calls in current script.

Example

localStorage.on("update", function(entry, value) {
	console.log("localStorage got updated:", entry, "=", value);
});