Sleekplan Logo
we run on Sleekplan

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.