dorukeker / gyronorm.js

JavaScript project for accessing and normalizing the accelerometer and gyroscope data on mobile devices
MIT License
641 stars 65 forks source link

fix: Prevent root attachment for exports #30

Closed GabrielGil closed 7 years ago

GabrielGil commented 7 years ago

This set of changes fixes #27

Both AMD and CommonJS do not require the exports to be scoped globally. This is, in the window object. Actually in this kind of cases, the root variable is undefined on import.

Creating an export object, makes possible to import GyroNorm with tools like webpack. A factorized GyroNorm model is then ready to use. An example using ES6 with Webpack would be:

import { GyroNorm } from 'gyronorm';

let gn = new GyroNorm();
  gn.init().then(() => {
    gn.start((data) => {
      console.log(data); // GyroNorm data.
    })
  })
  .catch((e) => {
    // Not Supported catch
  });

I would like to mention as well, that the best way would be to declare FullTilt as a dependency and do not include it manually on this project. However, due the license inconsistencies, and the lack of exports as well in that project, I believe it is better to make this little changes.

GabrielGil commented 7 years ago

Just compile and should be ready for release. Cheers! :)

GabrielGil commented 7 years ago

Hey @dorukeker, not sure if you could have a look at this yet. Cheers!

dorukeker commented 7 years ago

Hi Gabriel. It's been a busy week. I will pick it up soon. Cheers! On Wed, Feb 8, 2017 at 11:50 Gabriel notifications@github.com wrote:

Hey @dorukeker https://github.com/dorukeker, not sure if you could have a look at this yet. Cheers!

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/dorukeker/gyronorm.js/pull/30#issuecomment-278294949, or mute the thread https://github.com/notifications/unsubscribe-auth/ADtfPXQto_CB5ZwZk1rp4IQ_rfEHNj7Tks5raZ33gaJpZM4Lwg3H .

-- dorukeker.com | @dorukeker