mirror of
https://github.com/fluencelabs/gitbook-docs
synced 2025-06-15 07:51:34 +00:00
GitBook: [2.0.0] 31 pages and 13 assets modified
This commit is contained in:
committed by
gitbook-bot
parent
8ef255e0ba
commit
ba0a17719c
@ -31,9 +31,10 @@ To learn more about Aqua see [aqua book](https://doc.fluence.dev/aqua-book/)
|
||||
|
||||
The building block of the application are:
|
||||
|
||||
- Aqua code for peer-to-peer communication
|
||||
- Compiler cli package for aqua to \(java\)typescript compilation
|
||||
- Initialization of the `FluencePeer`
|
||||
- Application specific code \(java\)typescript in the framework of your choice
|
||||
* Aqua code for peer-to-peer communication
|
||||
* Compiler cli package for aqua to \(java\)typescript compilation
|
||||
* Initialization of the `FluencePeer`
|
||||
* Application specific code \(java\)typescript in the framework of your choice
|
||||
|
||||
In the next section we see it in action
|
||||
|
||||
|
@ -147,7 +147,7 @@ async function main() {
|
||||
main();
|
||||
```
|
||||
|
||||
\(1\) Import list of possible relay nodes (network enironment)
|
||||
\(1\) Import list of possible relay nodes \(network enironment\)
|
||||
|
||||
\(2\) Aqua compiler provides functions which can be directly imported like any normal typescript function.
|
||||
|
||||
@ -169,4 +169,5 @@ If everything has been done correctly yuo should see `Hello, world!` in the cons
|
||||
|
||||
The next secion will cover in-depth and advanced usage JS SDK
|
||||
|
||||
The code from this section is available in on (github)[https://github.com/fluencelabs/examples/tree/main/js-sdk-examples/hello-world]
|
||||
The code from this section is available in on \(github\)\[[https://github.com/fluencelabs/examples/tree/main/js-sdk-examples/hello-world](https://github.com/fluencelabs/examples/tree/main/js-sdk-examples/hello-world)\]
|
||||
|
||||
|
@ -8,13 +8,10 @@ In this section we will cover the JS SDK in-depth.
|
||||
|
||||
`@fluencelabs/fluence` exports a facade `Fluence` which provides all the needed functionality for the most uses cases. It defined 4 functions:
|
||||
|
||||
- `start`: Start the default peer.
|
||||
|
||||
- `stop`: Stops the default peer
|
||||
|
||||
- `getStatus`: Gets the status of the default peer. This includes connection
|
||||
|
||||
- `getPeer`: Gets the default Fluence Peer instance (see below)
|
||||
* `start`: Start the default peer.
|
||||
* `stop`: Stops the default peer
|
||||
* `getStatus`: Gets the status of the default peer. This includes connection
|
||||
* `getPeer`: Gets the default Fluence Peer instance \(see below\)
|
||||
|
||||
Under the hood `Fluence` facade calls the corresponding method on the default instance of FluencePeer. This instance is passed to the Aqua-compiler generated functions by default.
|
||||
|
||||
@ -137,7 +134,7 @@ Aqua compiler emits TypeScript or JavaScript which in turn can be called from a
|
||||
|
||||
For every exported function definition in aqua the compiler generated two overloads. One accepting the `FluencePeer` instance as the first argument, and one without it. Otherwise arguments are the same and correspond to the arguments of aqua functions. The last argument is always an optional config object with the following properties:
|
||||
|
||||
- `ttl`: Optional parameter which specify TTL \(time to live\) of particle with execution logic for the function
|
||||
* `ttl`: Optional parameter which specify TTL \(time to live\) of particle with execution logic for the function
|
||||
|
||||
The return type is always a promise of the aqua function return type. If the function does not return anything, the return type will be `Promise<void>`.
|
||||
|
||||
@ -167,7 +164,7 @@ export async function callMeBack(
|
||||
|
||||
### Service definitions
|
||||
|
||||
```
|
||||
```text
|
||||
service ServiceName:
|
||||
-- service interface
|
||||
```
|
||||
@ -186,9 +183,9 @@ export function registerServiceName(
|
||||
): void;
|
||||
```
|
||||
|
||||
- `peer` - the Fluence Peer instance where the handler should be registered. The peer can be ommited. In that case the default Fluence Peer will be used instead
|
||||
- `serviceId` - the name of the service id. If the service was defined with the default service id in aqua code, this argument can be ommited.
|
||||
- `service` - the handler for the service.
|
||||
* `peer` - the Fluence Peer instance where the handler should be registered. The peer can be ommited. In that case the default Fluence Peer will be used instead
|
||||
* `serviceId` - the name of the service id. If the service was defined with the default service id in aqua code, this argument can be ommited.
|
||||
* `service` - the handler for the service.
|
||||
|
||||
Depending on whether or not the services was defined with the default id the number of overloads will be different. In the case it **is defined**, there would be four overloads:
|
||||
|
||||
@ -277,9 +274,9 @@ export interface CalcDef {
|
||||
|
||||
Basic types convertion is pretty much straightforward:
|
||||
|
||||
- `string` is converted to `string` in typescript
|
||||
- `bool` is converted to `boolean` in typescript
|
||||
- All number types \(`u8`, `u16`, `u32`, `u64`, `s8`, `s16`, `s32`, `s64`, `f32`, `f64`\) are converted to `number` in typescript
|
||||
* `string` is converted to `string` in typescript
|
||||
* `bool` is converted to `boolean` in typescript
|
||||
* All number types \(`u8`, `u16`, `u32`, `u64`, `s8`, `s16`, `s32`, `s64`, `f32`, `f64`\) are converted to `number` in typescript
|
||||
|
||||
Arrow types translate to functions in typescript which have their arguments translated to typescript types. In addition to arguments defined in aqua, typescript counterparts have an additional argument for call params. For the majority of use cases this parameter is not needed and can be ommited.
|
||||
|
||||
@ -315,3 +312,4 @@ Tetraplets have the form of:
|
||||
To learn more about tetraplets and application security see [Security](https://github.com/fluencelabs/gitbook-docs/tree/77344eb147c2ce17fe1c0f37013082fc85c1ffa3/js-sdk/knowledge_security.md)
|
||||
|
||||
To see full specification of `CallParms` type see [Api reference](https://github.com/fluencelabs/gitbook-docs/tree/77344eb147c2ce17fe1c0f37013082fc85c1ffa3/js-sdk/js-sdk/6_reference/modules.md)
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
You can use the JS SDK with any framework \(or even without it\). The "flunce" part of the application is a collection of pure typesctipt\javascript functions which can be called withing any framework of your choosing.
|
||||
|
||||
See the browser-example which demonstrate integrating Fluence with React: (github)[https://github.com/fluencelabs/examples/tree/main/js-sdk-examples/browser-example]
|
||||
See the browser-example which demonstrate integrating Fluence with React: \(github\)\[[https://github.com/fluencelabs/examples/tree/main/js-sdk-examples/browser-example](https://github.com/fluencelabs/examples/tree/main/js-sdk-examples/browser-example)\]
|
||||
|
||||
Also take a look at FluentPad. It is an example application written in React: [https://github.com/fluencelabs/fluent-pad](https://github.com/fluencelabs/fluent-pad)
|
||||
|
||||
|
Reference in New Issue
Block a user