SleekplanSleekplan
All ideas

Better async support for $sleek SDK

The default JS snippet for the widget initializes $sleek to an empty array. This makes it impossible to start interacting with the API before the script finished loading. This makes it especially hard to use $sleek.on to register events since there is no way (that I'm aware of) to tell whether the "on" method is already available. I think it is an established pattern to queue commands until the SDK loaded, e.g. allow invoking methods via something like $sleek('on', 'open', ...) and replaying those invocations once the script finished loading. Alternatively, there could be a way to get notified when $sleek is ready via some sort of global callback function.

Activity · 4
Paul
Paul
@pageflow that makes totally sense. For now, we do not queue those calls, but you can use the global listener to make sure the SDK is ready. See SSO docs window.document.addEventListener('sleek:init', () => { //$sleek is ready to use }, false);
Paul
Paul
I'll keep these post open for the suggested option to "replaying those invocations once the script finished loading"
Team Pageflow
Team Pageflow
Great! So the global callback I was thinking of already exists.
Paul
Paul
@pageflow yes 🎉

More in Improvement