I am passing a complex object consisting of goog.structs.Set
from my content script to background page through chrome.extension.SendMessage
API. On the other side, this goog.structs.Set
is received as an Object
.
How can I typecast it back to goog.structs.Set
so that I can call various methods on it?
See http://developer.chrome.com/extensions/messaging.html, you can only pass JSON using chrome.extension.SendMessage.
Personally, I use a simple object as a set and avoid goog.structs.Set:
var MySet = Object.create(null);
If use must use goog.structs.Set, you will need to serialize and deserialize it to JSON.