IMPORTANT: Client and README are under heavy development and can be outdated. Ask a question in gitter or file an issue.
Fluence Javascript Client
Fluence Javascript Client allows you to interact with a real-time cluster from a browser or use it like npm
module.
Motivation
Browser client simplifies interaction with the real-time cluster for a user. It has zero dependencies and can be added to other code. Developers can deploy their backend code to Fluence network and built a web3 application based on Fluence Client to interact with this backend code. It is written on TypeScript to reach more clean, understandable and typesafe code with good reusability.
Documentation
Installation
npm install js-fluence-client
Before started
You need to have a deployed real-time cluster.
You can use this part of project to deploy 4-nodes cluster with increment
and multiply
functions as an example.
TODO: HOWTO deploy custom code (link to some other readme)
Init client and session
For interaction with the default increment and multiply
cluster you can use IncrementAndMultiply
class.
If we have a local cluster, we can initialize client like this:
;
Than we can use built-in functions:
// mutate state but returns nothingclient.incrementCounter; // get result after counter;console.logJSON.stringifycounter; // get result of moltiplying; // should be 13268console.logJSON.stringifyres;
If you deployed your own code, you can use CustomCommands
; // will return some result based on logic of deployed code;
If you want to write your own library, you can use IncrementAndMultiply.ts
as a basis:
;;;;;
You can find other examples in the examples folder.