pubnub / pubnub-angular

Official PubNub AngularJS SDK
Other
84 stars 43 forks source link

Errors out causing site to not load if PUBNUB is not defined #6

Open timjrobinson opened 10 years ago

timjrobinson commented 10 years ago

When PubNub is not loaded this script dies on line 26:

for (k in PUBNUB) {

with error "PUBNUB is not defined"

This shouldn't happen in production but during local dev I'm sometimes not connected to the internet and so pubnub is not initialized and this script breaks causing the whole site to not load.

sunnygleason commented 10 years ago

@timjrobinson interesting... what do you think would be the best solution?

I'm thinking of maybe providing a mock version of pubnub-angular that could be included for local development? (pubnub-angular-mock.js)

Let me know what you think -- this is a tricky case but I'll definitely see what we can do!

timjrobinson commented 10 years ago

I think the best solution would be to have it do nothing if pubnub is not loaded. I don't want to be able to use it when I'm offline I just don't want it to break the rest of the site so I can work on code unrelated to pubnub. All it really needs is checks whenever PUBNUB is used to ensure it's defined and if not return or callback with an error.