mirror of
https://github.com/fluencelabs/gitbook-docs
synced 2025-04-25 16:02:17 +00:00
Fix old version of typescript code
This commit is contained in:
parent
ba0a17719c
commit
836b911495
@ -31,9 +31,9 @@ service Calc("calc"):
|
||||
Now write the implementation for this service in typescript:
|
||||
|
||||
```typescript
|
||||
import { FluencePeer } from "@fluencelabs/fluence";
|
||||
import { Fluence } from "@fluencelabs/fluence";
|
||||
import { krasnodar } from "@fluencelabs/fluence-network-environment";
|
||||
import { registerCalc, CalcDef, demoCalculation } from "./_aqua/calc";
|
||||
import { registerCalc, CalcDef } from "./_aqua/calc";
|
||||
|
||||
class Calc implements CalcDef {
|
||||
private _state: number = 0;
|
||||
@ -74,25 +74,23 @@ const keypress = async () => {
|
||||
};
|
||||
|
||||
async function main() {
|
||||
await FluencePeer.default.init({
|
||||
await Fluence.start({
|
||||
connectTo: krasnodar[0],
|
||||
});
|
||||
|
||||
registerCalc(new Calc());
|
||||
|
||||
console.log("application started");
|
||||
console.log("peer id is: ", FluencePeer.default.connectionInfo.selfPeerId);
|
||||
console.log(
|
||||
"relay is: ",
|
||||
FluencePeer.default.connectionInfo.connectedRelays[0]
|
||||
);
|
||||
console.log("peer id is: ", Fluence.getStatus().peerId);
|
||||
console.log("relay is: ", Fluence.getStatus().relayPeerId);
|
||||
console.log("press any key to continue");
|
||||
await keypress();
|
||||
|
||||
await FluencePeer.default.uninit();
|
||||
await Fluence.stop();
|
||||
}
|
||||
|
||||
main();
|
||||
|
||||
```
|
||||
|
||||
As you can see all the service logic has been implemented in typescript. You have full power of npm at your disposal.
|
||||
|
Loading…
x
Reference in New Issue
Block a user