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

Illegal invocation #12

Open
Grandiz opened this issue May 30, 2016 · 2 comments
Open

Illegal invocation #12

Grandiz opened this issue May 30, 2016 · 2 comments

Comments

@Grandiz
Copy link

Grandiz commented May 30, 2016

if i call noble.on('stateChange', console.log); i will get an error

Illegal invocation
Noble.EventEmitter.emit
events.js @77:0

here is full code. could anyone help?

import React, { Component } from 'react';
import {
  AppRegistry,
  StyleSheet,
  Text,
  View,
    TouchableHighlight,
    DeviceEventEmitter
} from 'react-native';
import Orientation from 'react-native-orientation';

import { Accelerometer } from 'NativeModules';
var noble = require('react-native-ble');


Accelerometer.setAccelerometerUpdateInterval(5);
class arduinoCar extends Component {

    handlePressIn(){
        Accelerometer.startAccelerometerUpdates();
    }

    handlePressOut(){
        Accelerometer.stopAccelerometerUpdates();
    }

    componentWillMount(){
        noble.on('stateChange', console.log);
        //noble.on('discover', console.log);

    }

    componentDidMount(){
        Orientation.lockToLandscape();
        DeviceEventEmitter.addListener('AccelerationData', function (data) {
            console.log('acceleration data ', data.acceleration);
        });
    }

  render() {
    return (
      <View style={styles.container}>
          <TouchableHighlight underlayColor='#A74040'
                                style={styles.button}
                              onPressIn={this.handlePressIn}
                              onPressOut={this.handlePressOut}>
            <Text style={styles.buttonText}>Start</Text>
          </TouchableHighlight>
      </View>
    );
  }
}
AppRegistry.registerComponent('arduinoCar', () => arduinoCar);
@Shakarang
Copy link

Shakarang commented Jun 6, 2016

It's norman, you should give a handler. What you can do is
noble.on('stateChange', function(state) { // Your code here });

@DavoCg
Copy link

DavoCg commented Jun 14, 2016

but console.log is a handler !

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

No branches or pull requests

3 participants