Skip to content

Commit

Permalink
Add methods to unbind manager to make it possible to rebind if there …
Browse files Browse the repository at this point in the history
…is a need to change which type of layouts are to be scanned.
  • Loading branch information
Juha Linnanen committed Oct 12, 2017
1 parent 5c8dbd6 commit f1957ba
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ public void bindManager() {
mBeaconManager.bind(this);
}

@ReactMethod
public void unbindManager() {
mBeaconManager.unbind(this);
}

@ReactMethod
public void addParser(String parser) {
mBeaconManager.getBeaconParsers().add(new BeaconParser().setBeaconLayout(parser));
Expand Down
27 changes: 23 additions & 4 deletions lib/next/new.module.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,34 @@ async function bindManager(): Promise<any> {
return new Promise((resolve, reject) => {
this.bindListener = DeviceEventEmitter.addListener('bindStatus', ({status}) => {
if (status) {
resolve(status)
resolve(status);
}
else {
reject(status)
reject(status);
}
DeviceEventEmitter.removeListener('bindStatus', this.bindListener)
DeviceEventEmitter.removeListener('bindStatus', this.bindListener);
});
BeaconsManager.bindManager();
})
});
}

/**
* unbind the service
*
*/
async function unbindManager(): Promise<any> {
return new Promise((resolve, reject) => {
this.bindListener = DeviceEventEmitter.addListener('bindStatus', ({status}) => {
if (status) {
resolve(status);
}
else {
reject(status);
}
DeviceEventEmitter.removeListener('bindStatus', this.bindListener);
});
BeaconsManager.unbindManager();
});
}

/**
Expand Down

0 comments on commit f1957ba

Please sign in to comment.