-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
1,175 additions
and
316 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Examples | ||
|
||
- [Hello, World](./hello_world) | ||
|
||
- [Counter](./counter) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
[package] | ||
name = "example" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
qubit = { path = "../../" } | ||
axum = "0.6.20" | ||
futures = "0.3.30" | ||
http = "0.2.9" | ||
hyper = { version = "0.14.10", features = ["server"] } | ||
serde = { version = "1.0.195", features = ["derive"] } | ||
serde_json = "1.0.111" | ||
tokio = { version = "1.35.1", features = ["rt", "rt-multi-thread"] } | ||
tower = "0.4.13" | ||
ts-rs = "8.1.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import type { Stream } from "@qubit-rs/client"; | ||
export type Metadata = { param_a: string, param_b: number, param_c: boolean, more_metadata: Metadata | null, }; | ||
export type Test = { a: number, b: boolean, }; | ||
export type User = { name: string, email: string, age: number, metadata: Metadata, }; | ||
|
||
export type Server = { version: () => Promise<string>, count: () => Promise<number>, countdown: (min: number, max: number) => Stream<number>, array: () => Promise<Array<string>>, user: { someHandler: (_id: string) => Promise<User>, create: (name: string, email: string, age: number) => Promise<User>, list: () => Promise<Array<Test>>, asdf: () => Promise<null> } }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { ws } from "@qubit-rs/client"; | ||
import type { Server } from "./bindings.ts"; | ||
|
||
const client = ws<Server>("ws://localhost:9944/rpc"); | ||
|
||
client.version().then((version) => console.log({ version })).catch(console.error); | ||
client.user.someHandler("test").then((user) => console.log(user)).catch(console.error); | ||
client.count().then((value) => console.log({ value })).catch(console.error); | ||
|
||
client.countdown(1, 4).subscribe({ | ||
on_data: (data) => { | ||
console.log("countdown: ", data); | ||
}, | ||
on_end: () => { | ||
console.log("countdown done"); | ||
} | ||
}); | ||
|
||
client.countdown(1, 4) | ||
.subscribe((n) => console.log("number is", n)) |
Oops, something went wrong.