PostToRuntime(handler, data)

0 favourites
  • 6 posts
From the Asset Store
Data+ is the best Data Management solution for Construct 3. It contains 4 Addons (Plugin & Behavior).
  • Hi Ashley,

    Is the PostToRuntime(handler, data) an official SDK method, I can't seem to find it in the SDK and it is the method that best suits my addons. I can only find PostToRuntimeAsync being mentioned. Can you confirm?

    Thank you.


  • Also, could you confirm if we can use these methods as well?

    this.AddDOMMessageHandlers([[handler, e => callback(e)]]);
    this.AddRuntimeMessageHandlers([[handler, e => callback(e)]]);

    Thank you.

  • What do you need this for? If it's related to this thread, as per my reply, you may be able to entirely avoid having to use a DOM-side script. If you can, that is definitely preferable, both for you and for us as we don't have more runtime code that risks breaking third-party addons whenever we change it.

  • Thank you for your advice.

    However, this was actually a different matter, this is regarding Cordova plugins. It looks like the easiest way to handle traditional callbacks, in my opinion after porting a few addons.

    This is my sample:

    	["on-mobile-sdk", e => this._OnMobileSDK(e)]
    	["StartSDK", e=> this._StartSDK(e)],
    	["Initialize", e => this._Initialize(e)]


    // Dom-Side.js
    	if (this._isMobile)
    		this._SDK = window["plugins"]["sdk"];
    		this.PostToRuntime("on-mobile-sdk", {});
    		console.warn("[Mobile SDK] You need to export to mobile in order to run.");
    // Instance.js
     this._isMobile = true;

    This is more effective as you add more methods, the ones above are for the purpose of visualization.

    I was wondering if these are valid official SDK methods or should I rewrite it to what's supported. If it's not supported, could you kindly give me a quick reference to the methods I should use instead?

    Thank you.

  • Ah, OK. That looks about right, and is a similar pattern we use in Construct itself. It's true there is some documentation missing for this. I've updated the docs to cover SDKInstanceBase AddDOMMessageHandlers and a new page for the DOMHandler base class which has the runtime messaging features. As per our support policy, now these are documented we promise to support them.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • That's great! Thank you for the new additions.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)