Decouple the library from the example
See original GitHub issueThe current demo works really well, but it is rather painful to reuse.
My understanding is that dfu.js
and dfuse.js
were thought as an easily-reusable library, and that dfu-util.js
is responsible for hooking up the library to the demo HTML.
The problem is, dfu-util.js
still does some heavy lifting : for example, see the connect function which tries to figure out if a given device is DfuSe-compliant or not. Re-using this code currently means duplicating this function.
It would be very useful to have a minimal UI-less demo to make sure reusing this library is easy.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:3
- Comments:7 (3 by maintainers)
Top Results From Across the Web
How to Use Python Decouple - Simple is Better Than Complex
Python Decouple is a great library that helps you strictly separate the settings parameters from your source code. The idea is simple: ...
Read more >python-decouple - PyPI
Python Decouple: Strict separation of settings from code. Decouple helps you to organize your settings so that you can change parameters without having...
Read more >Decoupling from 3rd party library - java - Stack Overflow
This is a classic case of the Mediator design pattern: The class which uses the HTTP client shouldn't be exposed to neither the...
Read more >How do I decouple this coupled application?
Decoupling using interfaces. The challenge in your design, is to have "independent" bots and an "independent" viewer and being able to ...
Read more >A simple recipe for framework decoupling - Matthias Noback
Sometimes a dependency uses IO, that is, it talks to the database, the filesystem, etc. In that case you should introduce an abstraction...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I haven’t tried this personally (or Node.js, for that matter), but there is a Node.js implementation of the WebUSB spec that you could try: https://github.com/thegecko/webusb
Yeah,
dfu.js
anddfuse.js
are more or less directly ported from dfu-util, whereasdfu-util.js
is a bit more interactive than the real dfu-util.My initial thoughts for refactoring some of that logic would be to add a new
connectDfuInterface
function that would absorb the descriptor-reading code inconnect
and in the call tonavigator.usb.requestDevice
. The user could then pass in an async callback to handle selecting the interface (which could either be interactive or pick a known-in-advance interface by interface number, name, etc).