nathankellenicki / node-poweredup

A Javascript module to interface with LEGO Powered Up components.
https://nathankellenicki.github.io/node-poweredup/
MIT License
477 stars 59 forks source link

wechat miniprogram environment support #160

Closed 0x5e closed 2 years ago

0x5e commented 2 years ago

Hi all: In China, miniprogram is very popular and widely used in WeChat, Alipay and other big apps. WeChat miniprogram provide some BLE apis so it's able to connect the lego hub. I want to fork this repo and support the miniprogram environment, If I add the code everywhere like this, it's not pretty:

if (inWeChatMiniProgram) {
    wx.startDiscovery(...);
} else {
    noble.startDiscovery(...);
}

Any suggestions? What do you think of the code having many types: node, browser, wechat miniprogram, or other environments in future?