Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upSome ideas for API improvements #1412
Open
Labels
Comments
This comment has been minimized.
This comment has been minimized.
|
Thanks for the thoughtful suggestions. I'd like to consider some of these ideas when we release a promise-based API sometime in the future. I think @DiegoRBaquero had interest in working on this at open point. |
This comment has been minimized.
This comment has been minimized.
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
While I was working on my magnet-protocolhandler project, I noticed a few things that have been a bit inconvenient:
While writing a webapp where a magnet url can be entered, it's quiet tempting to just use client.add, but if the same torrent is entered again, it will fail. After I noticed this, I used client.get first, and than either waited for the torrents ready event if it was already added or use client add otherwise. But then I notices that I can miss the ready event, so I had to check if the torrent was already ready first. I ended up with the following function:
Since this seams like a pretty common use case, and it's so easy to get wrong, it would be nice to have something like this as a convenience function, or alternatively a parameter for the add function so it can be used for the same torrent more than once.
Currently, there is only a constructor using which any number of webtorrent instances can be created. If multiple independent libraries use webtorrent, they need to obtain a webtorrent instance, so they may all create a new one. But what would the implications of that be? The instances wouldn't share the added torrents and other things, so could that lead to a lot of resources wasted if multiple libraries add the same torrent, for example?
I think it would be nice to have a singleton function, so that all libraries can use that function to get a single shared webtorrent instance. I'm just not sure what to do about the options that can be passed to the webtorrent constructor in that case though.
Lastly, I would like to thank everyone for creating this truly awesome library.