question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Decouple the library from the example

See original GitHub issue

The 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:open
  • Created 6 years ago
  • Reactions:3
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
devanlaicommented, Jul 19, 2018

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

1reaction
devanlaicommented, Oct 29, 2017

Yeah, dfu.js and dfuse.js are more or less directly ported from dfu-util, whereas dfu-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 in connect and in the call to navigator.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).

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found