mirror of
https://github.com/fluencelabs/gitbook-docs
synced 2025-04-26 00:12:14 +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:
|
Now write the implementation for this service in typescript:
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
import { FluencePeer } from "@fluencelabs/fluence";
|
import { Fluence } from "@fluencelabs/fluence";
|
||||||
import { krasnodar } from "@fluencelabs/fluence-network-environment";
|
import { krasnodar } from "@fluencelabs/fluence-network-environment";
|
||||||
import { registerCalc, CalcDef, demoCalculation } from "./_aqua/calc";
|
import { registerCalc, CalcDef } from "./_aqua/calc";
|
||||||
|
|
||||||
class Calc implements CalcDef {
|
class Calc implements CalcDef {
|
||||||
private _state: number = 0;
|
private _state: number = 0;
|
||||||
@ -74,25 +74,23 @@ const keypress = async () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
await FluencePeer.default.init({
|
await Fluence.start({
|
||||||
connectTo: krasnodar[0],
|
connectTo: krasnodar[0],
|
||||||
});
|
});
|
||||||
|
|
||||||
registerCalc(new Calc());
|
registerCalc(new Calc());
|
||||||
|
|
||||||
console.log("application started");
|
console.log("application started");
|
||||||
console.log("peer id is: ", FluencePeer.default.connectionInfo.selfPeerId);
|
console.log("peer id is: ", Fluence.getStatus().peerId);
|
||||||
console.log(
|
console.log("relay is: ", Fluence.getStatus().relayPeerId);
|
||||||
"relay is: ",
|
|
||||||
FluencePeer.default.connectionInfo.connectedRelays[0]
|
|
||||||
);
|
|
||||||
console.log("press any key to continue");
|
console.log("press any key to continue");
|
||||||
await keypress();
|
await keypress();
|
||||||
|
|
||||||
await FluencePeer.default.uninit();
|
await Fluence.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
main();
|
main();
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
As you can see all the service logic has been implemented in typescript. You have full power of npm at your disposal.
|
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