RangerMauve / hyper-sdk

Make your own hyper apps!
https://www.youtube.com/watch?v=HyHk4aImd_I&list=PL7sG5SCUNyeYx8wnfMOUpsh7rM_g0w_cu&index=20
MIT License
290 stars 46 forks source link

Expose `addExtensions` API #3

Closed martinheidegger closed 5 years ago

martinheidegger commented 5 years ago

I am assuming that "addExtension" should work whenever called from a code perspective, but from an API perspective I believe it could be a problem for developers to understand that calling addExtensions is usually desirable before setting up the hyperdrive.

Maybe there should be an error/warning or API-system that only allows to set it before?

https://github.com/datproject/sdk/blob/9cc14f2a8a150f5753a3ce6709d0151fe701bc81/index.js#L31-L38

RangerMauve commented 5 years ago

Thanks for looking into this!

addExtensions gets invoked whenever you stat tracking a Hyperdrive or Hypercore so developers are never going to need to invoke it manually.

Ideally they shouldn't need to know it exists. :P

martinheidegger commented 5 years ago

Make it private _addExtensions ?

RangerMauve commented 5 years ago

What's the use case for doing it via that instead of the constructors?

martinheidegger commented 5 years ago

I just read over the code again, and noticed that it was a misunderstanding on my side, namely: I thought addExtensions is a public method; it is not and that is a totally different issue. Let me open a new issue for that.