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

Add a method that converts a characteristic into an observable of values #7

Closed
urish opened this issue Feb 9, 2017 · 0 comments · Fixed by #9
Closed

Add a method that converts a characteristic into an observable of values #7

urish opened this issue Feb 9, 2017 · 0 comments · Fixed by #9

Comments

@urish
Copy link
Contributor

urish commented Feb 9, 2017

sketch for a possible implementation:

  notifications$(char: BluetoothRemoteGATTCharacteristic) {  
    char.startNotifications();
    const disconnected = Observable.fromEvent(char.service.device as any, 'gattserverdisconnected');
    return Observable.fromEvent(char as any, 'characteristicvaluechanged').takeUntil(disconnected).map(event => event.target.value as DataView);
  }

You'd still need to stop the notifications when everybody unsubscribes, but I guess this can be added later.

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 a pull request may close this issue.

1 participant