[DEPRECATED]: This project/library has been moved to https://github.com/textileio/js-threads
Textile's JS client for interacting with remote Threads
Go to the docs for more about Textile.
Join us on our public Slack channel for news, discussions, and status updates. Check out our blog for the latest posts and announcements.
npm install @textile/threads-client
create a threads client
import {Client} from '@textile/threads-client'
client = new Client()
create a threads client using Textile APIs
import {API} from '@textile/textile'
import {Client} from '@textile/threads-client'
const api = new API({
token: '<project token>',
deviceId: '<user id>'
})
await api.start()
const client = new Client(api.threadsConfig)
create a store
const store = await client.newDB()
await client.newCollection(store.id, 'Folder2P', schema)
get all instances
const found = await client.find(this.finderID, 'Folder2P', {})
console.debug('found:', found.instancesList.length)
this.folders = found.instancesList.map((instance) => instance).map((obj) => {
return new YourModel(obj)
})
add an instance
// matches YourModel and schema
const created = await client.instanceCreate(this.finderID, 'Folder2', [{
some: 'data',
numbers: [1, 2, 3]
}])
The following has been tested on Android Only.
js-thread-client
should be compatible with React Native. Here are some helpful pointers if you find issues testing it out.
You can run the daemon released as part of the early preview. To do so,
git clone git@github.com:textileio/go-threads.git
cd go-threads
go run threadsd/main.go
Make daemon available to RN
You can make the daemon API port available to your app with,
adb reverse tcp:6007 tcp:6007
Altenatively, you can ensure this is run whenever you run your app by modifying your package.json
as follows.
{
...
"scripts": {
...
"bind": "adb reverse tcp:6007 tcp:6007",
"android": "npm run bind && npx react-native run-android",
...
},
...
}
Then, run your app with,
npm run android
js-threads-client
relies on Buffer being available. To make Buffer
available in your project, you may need to introduce a shim. Here are the steps.
install rn-nodeify
read more about rn-nodeify.
npm install -G rn-nodeify
run nodeify in the root of your project
rn-nodeify --install buffer --hack
This will create a shim.js
in the root of your project. You need to import this at the top of your apps entry file (e.g. indes.js
).
The top of index.js
would look like,
require('./shim')
...
add nodeify to your postinstall
Ensure that the shim is still configured after any module updates. Inside package.json
add the following line to your scripts
tag,
{
...
"scripts": {
...
"postinstall": "rn-nodeify --install buffer --hack"
}
}
This project is a work in progress. As such, there's a few things you can do right now to help out:
Before you get started, be sure to read our contributors guide and our contributor covenant code of conduct.
Changelog is published to Releases.