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
Proposed simplification of users APIs #157
Conversation
Signed-off-by: Carson Farmer <carson.farmer@gmail.com>
Signed-off-by: Carson Farmer <carson.farmer@gmail.com>
Signed-off-by: Carson Farmer <carson.farmer@gmail.com>
94cac10
to
535c8cb
Compare
}).timeout(3000) | ||
|
||
it('should then create a db for the bucket', async function () { | ||
await users.newDB(ThreadID.fromRandom(), users.context.withThreadName('my-buckets')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be cleaned up slightly
transport: context.transport, | ||
debug: context.debug, | ||
}) | ||
// Module augmentation to add methods to Peer from core |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is pretty cool, we essentially extend the Client interface on the fly here, and then the implementations follow
*/ | ||
Client.prototype.getThread = async function (name: string, ctx?: Context) { | ||
logger.debug('get thread request') | ||
const client = new APIClient(this.serviceHost, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because we're 'piggy backing' off of threads client, we create out own client here each time, but use all the options and settings from threads client.
} | ||
|
||
export { Client } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exported for convinience, but these new methods should exist even if we import and let side-effects take over
Signed-off-by: Carson Farmer <carson.farmer@gmail.com>
With these changes, if you do: import { Client, Buckets } from '@textile/textile` you essentially have all the hub-based APIs you'd want. This PR augments Client with User API methods getThread and listThreads, so developers can more easily manage threads without having to interact with a whole new set of APIs, or the low level Network Client APIs. If they aren't using Buckets, they could also do: import '@textile/textile` and still get the augmented Client with the Users APIs, as this code also provides side-effects to augment the Client. |
@andrewxhill, here's a proposed simplified workflow for you. I'll make comments inline, please let me know what you think.