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

Make webcamjs more node-friendly #155

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

sjdemartini
Copy link

The primary change here is to not initialize with an explicit window dependency.

This allows the module to be imported on the server, since it can be exported without requiring the window. The init() call that used to happen before exporting the module now happens automatically when attaching a webcam viewer for the first time.

This solution is not as heavy-handed as #66, in that this does not allow for separate Webcam instances (e.g., does not allow for multiple independent Webcam previews to have separate flashNotify callbacks), but does improve modularization. Ultimately, that approach is probably preferred, but these changes will allow for at least this simple implementation to work in a node environment.

This allows the module to be imported on the server, since it can be
exported without requiring the `window`. The init() call that used to
happen before exporting the module now happens automatically when
attaching a webcam viewer for the first time.
@jhuckaby
Copy link
Owner

Thanks man! I'll look this over as soon as I have some time.

@positlabs
Copy link

Traditionally, node is headless. What is the goal here? Electron support? Or more general support for modules?

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

Successfully merging this pull request may close these issues.

3 participants