Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ifvisible is not defined #9

Closed
henryruhs opened this issue Jul 20, 2015 · 6 comments
Closed

ifvisible is not defined #9

henryruhs opened this issue Jul 20, 2015 · 6 comments

Comments

@henryruhs
Copy link

Please confirm that ifvisible.js was loaded before you using it. Maby you pass it via the closure:

(function (ifvisible) {

if (typeof ifvisible === 'object') {
}

})(this.ifvisible);
@jasonzissman
Copy link
Owner

Good idea! Do you have any recommendations on what to do if ifvisible is not defined? I could include a console.log() message, but I don't know if people typically want log messages (even during exceptional cases like this) to be written to the console. Perhaps I should throw an exception instead?

@henryruhs
Copy link
Author

I suggest to write an internal method getVisible or ifVisible for the external library like:

(function (ifvisible) {
..
..
..
getVisible: function() {
    if (typeof ifvisible === 'object') {
      //return the ifvisible object
    }
    else {
      throw 'error, warning or whatever you think';
    }
}
..
..
})(this.ifvisible);

Later on I suggest to use this internal method / wrapper inside a listen method that is made for the event handling... ifvisible.on(...)

listen: function () {
     ..
    TimeMe.getVisible.on('...')
     ..
}

Finally you let the user start the listen method or add it to your init method.

@jasonzissman
Copy link
Owner

I put together a pull request: #11. Care to take a look at it? Thanks as always for the help.

@henryruhs
Copy link
Author

Looks good

@henryruhs
Copy link
Author

Please create a new tag like 1.1.0

@jasonzissman
Copy link
Owner

Done!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants