-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Split up the API to smaller parts #9
Comments
This is a totally valid point, however nothing precludes you from implementing a provider that throws on certain methods. In fact, that's what I do now in Joule (and was doing before I had implemented
This actually isn't the case. Joule gives that permission by default right now, but nothing would stop me from allowing the user to not provide this information, and just throwing on I agree that there should probably be some kind of OAuth style permission requesting in |
Of course, throwing is an option, the question is whether websites will handle it correctly. I'm not experienced in web development, so maybe the culture of web is good enough that this is non-issue and in that case, sorry for bothering. What I found when programming is that rather than throwing/returning errors, it's better to no provide the function at all, so that the user of API is forced to check it. Of course this is implying strict null checking. If you choose to recommend throw and catch approach, please at least document what can throw and when, as I wasn't sure from just looking at the interface documentation. (But maybe "everything can throw, you must catch everything" is implied in JS and it's just me not knowing JS enough?) |
Typically promises are expected to throw due to the nature of them usually dealing with network requests, file system access, etc. But you're absolutely right, this could be more explicit. Each of the methods are going to need much more documentation and examples at some point, so I'll definitely be sure to outline the errors they can throw (and ideally standardize them into actual error classes instead of them all being generic I'm going to close this issue and open two new ones with the things above. |
OK, I've also opened an issue in Joule for addressing permissions. Thank you for explanation and consideration! |
Currently, the API allows one to either implement everything or nothing at all. This goes against interface segregation principle. Some issues this leads to:
My suggestion would be to split the interface into these parts:
The specification should not require extensions to implement every part and should recommend websites to handle missing features by disabling relevant features of the website instead of ignoring the API completely (e.g. Lightning Spin could make use of invoices APIs and ignore the rest, if it isn't provided).
Further, this allows extending the interface more cleanly in the future (e.g. adding channel manipulation API, on-chain API, etc), as new additions would be separate from existing and still optional, thus not breaking any old implementations. This is also a very good reason for recommending granular handling of errors.
The text was updated successfully, but these errors were encountered: