applest / node-applest-atem

A module to control Blackmagic Design ATEM Switchers
88 stars 30 forks source link

scoping issues #14

Closed TomKaltz closed 8 years ago

TomKaltz commented 8 years ago

I'm running into issues using this library in my project. When I call prototype functions like autoTransitions() from a callback where this is not the original ATEM object I get errors. Might be something having to do with CoffeeScript. It's making this library unusable in my project because I can't call prototype methods from outside the ATEM class context.

module.exports = function(otherThing){
  var ATEM = require('applest-atem');
  var atem = new ATEM();

  atem.on('connect', function() {
        setInterval(function() {
            atem.autoTransition(); //THIS WORKS
        }, 1000)
    });

  otherThing.on('someEvent',function(){
    atem.autoTransition(); //DOES NOT WORK
  });

  return atem;
}
TomKaltz commented 8 years ago

This may not be an issue after all. It may be something having to do with my build system. Please disregard.