hypeDocument.customData quick examples of setting and getting data

It’s currently just a place to pass around data from scene to scene and specially Hype function to Hype function as the API for the current Hype document is held in it’s parent hypeDocument passed into every Hype function (see signature of the Hype functions).

In it’s current form in the API it’s actually only a plain Object. But it’s mighty convenient as it is local to your Hype document and with it’s “mount point” in hypeDocument omnipresent to local Hype functions in your current document.

That said there is nothing stopping you from creating hypeDocument.myCustomData={}; but introducing an official mount point helps to unify the places we start mounting such things. Also if the day comes the API locks down full write access to it’s API Object hypeDocument (hope that never happens) it would offer an official place to add data.

For persistence on customData with some added benefits have a look at Hype StorageKit. If you want to write something yourself just use localStorage on the customData object as that isn’t persistent in it’s current form nor does it intend to be.

2 Likes