-
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.
allow for
.subscribe
to be overloaded
- Loading branch information
Showing
5 changed files
with
39 additions
and
15 deletions.
There are no files selected for viewing
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 @@ | ||
--- | ||
"@qubit-rs/client": minor:feat | ||
--- | ||
|
||
allow for subscription method to be overloaded if only `on_data` is required. |
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 |
---|---|---|
@@ -1,5 +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>, 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> } }; | ||
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
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 |
---|---|---|
@@ -1,9 +1,13 @@ | ||
export type StreamSubscriber<T> = ({ on_data, on_error, on_end }: { | ||
on_data?: (data: T) => void, | ||
on_error?: (error: Error) => void, | ||
on_end?: () => void, | ||
}) => () => void; | ||
export type StreamSubscriber<T> = ( | ||
handler: | ||
| ((data: T) => void) | ||
| { | ||
on_data?: (data: T) => void; | ||
on_error?: (error: Error) => void; | ||
on_end?: () => void; | ||
}, | ||
) => () => void; | ||
|
||
export type Stream<T> = { | ||
subscribe: StreamSubscriber<T>, | ||
subscribe: StreamSubscriber<T>; | ||
}; |