As of April 12th, you must go to Progress SupportLink to create new support cases or to access existing cases. Please, bookmark the SupportLink URL and use the new portal to contact the support team.
Is there currently a method to check if the Kinvey class is initialized in the HTML5 library? Right now even after the JS file is loaded attempting to call Kinvey.getActiveUser() before Kinvey.init() will actually throw a Kinvey error. Since it seems the Kinvey.Error class extends the actual native Error and throws it, all execution following the failed .getActiveUser is stopped.
I understand why this might be ideal in certain situations, but right now we are forced to set and manage our own "kinveyReady" variable and check it before calling Kinvey.getActiveUser(). When doing an HTML5 app using appcache and hash routing things can initialize very quickly upon refresh/load, so maybe throwing a hard error isn't the best - however at the least would it be possible to get some kind of "isInitialized" or "ready" method against the base Kinvey class?
You have to call `Kinvey.init()` first. This method sets the appropriate variables which are used by `Kinvey.getActiveUser()`. How are you maintaining your `kinveyReady` variable?
O
OhmzTech
said
over 9 years ago
I know that Kinvey.init() needs to be called first to actually use Kinvey.getActiveUser(), however I guess what I'm asking for is a way to have it return with a non-stopping error if it's called before Kinvey.init(). Right now we are simply setting a global variable to true in the Kinvey.init() callback, and checking it again whenever we use Kinvey.getActiveUser() in a feature condition. Since frequently you might find these in if-else statements, you still want the else to execute (if Kinvey is not initialized OR there is no active user) and as it is right now (calling just Kinvey.getActiveUser()) causes further code execution to stop.
Let me know if this makes sense, or if you need more information. I really don't think there is a way to do with right now (I've inspected 1.1.3 library source pretty well), so this is more of a future feature request.
M
Mark
said
over 9 years ago
For now, I’d recommend wrapping `Kinvey.getActiveUser()` in a `try-catch`. This way, it is easy to determine your condition of Kinvey is not initialized OR there is no active user:
Your example would work just fine, however it requires a substantial amount of code (in top of that, the try/catch would need to be done before the if statement). You are accomplishing the same thing really - dealing with an external variable tracking initialization status. Since getActiveUser() is a frequently occurrence I'm just wondering if the Kinvey lib can eventually expose a variable/method to check this, or have getActiveUser() throw a softer error.
M
Mark
said
over 9 years ago
I could add an `Kinvey.isInitialized()` method.
By the way, the 1.1.3 equivalent would be `null == Kinvey.appKey`, since that's only set through the `Kinvey.init` method. So it would become:
OhmzTech
I understand why this might be ideal in certain situations, but right now we are forced to set and manage our own "kinveyReady" variable and check it before calling Kinvey.getActiveUser(). When doing an HTML5 app using appcache and hash routing things can initialize very quickly upon refresh/load, so maybe throwing a hard error isn't the best - however at the least would it be possible to get some kind of "isInitialized" or "ready" method against the base Kinvey class?