agsh / onvif

ONVIF node.js implementation
https://onvif.pages.dev
MIT License
703 stars 240 forks source link

Removes cylic dependencies so it can be used in React Native #97

Closed lattice0 closed 6 years ago

lattice0 commented 6 years ago

I had a hard time figuring out why this module didn't work on react native even though I mapped nodejs's net and stream libraries to React Native compatible ones. Turns out it was a problem with cyclic dependencies in the way you splits class definition in the library.

The best method I could find was to pass the already half built class object in the moment I require a new one, like this:

Cam = function() {
...
}

require('./devices')(Cam)
require('./media')(Cam)
...

I didn't touch any other part of the code but the diffs are kinda wrong.

It's kinda ugly but it's necessary. Don't know if this is going to serve you but would be nice to have it working in both nodejs and react native. And I'm also going to build a good onvif app with it, because the ones in play store and app store don't fit my need.

agsh commented 6 years ago

Hi Lucas!

Can you fix jslint and jscs style code errors to test functionality with Travis CI?

coveralls commented 6 years ago

Coverage Status

Coverage increased (+0.1%) to 86.943% when pulling 336a8cabf48663d1707262bb51a3115ec13d6b78 on lucaszanella:master into 5d940b56df23f277382a08e61a6bccf6c65cbab1 on agsh:master.

lattice0 commented 6 years ago

Hi. Now it's passing

agsh commented 6 years ago

Lucas, thanks a lot for this PR!