Skip to content

Make webcamjs more node-friendly#155

Open
sjdemartini wants to merge 2 commits intojhuckaby:masterfrom
sjdemartini:improvements-for-node-usage
Open

Make webcamjs more node-friendly#155
sjdemartini wants to merge 2 commits intojhuckaby:masterfrom
sjdemartini:improvements-for-node-usage

Conversation

@sjdemartini
Copy link
Copy Markdown

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
Copy Markdown
Owner

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

@positlabs
Copy link
Copy Markdown

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