summaryrefslogtreecommitdiff
path: root/frontend/src/api/sevenWondersApi.js
diff options
context:
space:
mode:
authorJoffrey BION <joffrey.bion@gmail.com>2017-07-24 23:51:43 +0200
committerJoffrey BION <joffrey.bion@gmail.com>2017-07-24 23:52:40 +0200
commit324b51049acac27ea3e7f71acad47aa729dfd8db (patch)
tree198640ae8788e6275e061cf38cea621206160bbf /frontend/src/api/sevenWondersApi.js
parentUpgrade flow-bin (diff)
downloadseven-wonders-324b51049acac27ea3e7f71acad47aa729dfd8db.tar.gz
seven-wonders-324b51049acac27ea3e7f71acad47aa729dfd8db.tar.bz2
seven-wonders-324b51049acac27ea3e7f71acad47aa729dfd8db.zip
Improve sevenWondersApi and types
Diffstat (limited to 'frontend/src/api/sevenWondersApi.js')
-rw-r--r--frontend/src/api/sevenWondersApi.js46
1 files changed, 24 insertions, 22 deletions
diff --git a/frontend/src/api/sevenWondersApi.js b/frontend/src/api/sevenWondersApi.js
index 1004c81e..9a68ec66 100644
--- a/frontend/src/api/sevenWondersApi.js
+++ b/frontend/src/api/sevenWondersApi.js
@@ -1,5 +1,7 @@
-import { createJsonStompClient, JsonStompClient, Callback } from './websocket';
-import { ApiError, ApiLobby, ApiPlayer, ApiPlayerMove, ApiPlayerTurnInfo, ApiPreparedCard, ApiTable } from './model';
+// @flow
+import { createJsonStompClient } from './websocket';
+import type { JsonStompClient, SubscribeFn } from './websocket'
+import type { ApiError, ApiLobby, ApiPlayer, ApiPlayerMove, ApiPlayerTurnInfo, ApiPreparedCard, ApiTable } from './model';
const wsURL = '/seven-wonders-websocket';
@@ -10,32 +12,32 @@ export class SevenWondersSession {
this.client = client;
}
- watchErrors(callback: Callback<ApiError>): void {
- return this.client.subscribe('/user/queue/errors', callback);
+ watchErrors(): SubscribeFn<ApiError> {
+ return this.client.subscriber('/user/queue/errors');
}
chooseName(displayName: string): void {
this.client.send('/app/chooseName', { playerName: displayName });
}
- watchNameChoice(callback: Callback<ApiPlayer>): void {
- return this.client.subscribe('/user/queue/nameChoice', callback);
+ watchNameChoice(): SubscribeFn<ApiPlayer> {
+ return this.client.subscriber('/user/queue/nameChoice');
}
- watchGames(callback: Callback<ApiLobby[]>): void {
- return this.client.subscribe('/topic/games', callback);
+ watchGames(): SubscribeFn<ApiLobby[]> {
+ return this.client.subscriber('/topic/games');
}
- watchLobbyJoined(callback: Callback<Object>): void {
- return this.client.subscribe('/user/queue/lobby/joined', callback);
+ watchLobbyJoined(): SubscribeFn<Object> {
+ return this.client.subscriber('/user/queue/lobby/joined');
}
- watchLobbyUpdated(currentGameId: number, callback: Callback<Object>): void {
- return this.client.subscribe(`/topic/lobby/${currentGameId}/updated`, callback);
+ watchLobbyUpdated(currentGameId: number): SubscribeFn<Object> {
+ return this.client.subscriber(`/topic/lobby/${currentGameId}/updated`);
}
- watchGameStarted(currentGameId: number, callback: Callback<Object>): void {
- return this.client.subscribe(`/topic/lobby/${currentGameId}/started`, callback);
+ watchGameStarted(currentGameId: number): SubscribeFn<Object> {
+ return this.client.subscriber(`/topic/lobby/${currentGameId}/started`);
}
createGame(gameName: string): void {
@@ -50,20 +52,20 @@ export class SevenWondersSession {
this.client.send('/app/lobby/startGame');
}
- watchPlayerReady(currentGameId: number, callback: Callback<string>): void {
- return this.client.subscribe(`/topic/game/${currentGameId}/playerReady`, callback);
+ watchPlayerReady(currentGameId: number): SubscribeFn<string> {
+ return this.client.subscriber(`/topic/game/${currentGameId}/playerReady`);
}
- watchTableUpdates(currentGameId: number, callback: Callback<ApiTable>): void {
- return this.client.subscribe(`/topic/game/${currentGameId}/tableUpdates`, callback);
+ watchTableUpdates(currentGameId: number): SubscribeFn<ApiTable> {
+ return this.client.subscriber(`/topic/game/${currentGameId}/tableUpdates`);
}
- watchPreparedMove(currentGameId: number, callback: Callback<ApiPreparedCard>): void {
- return this.client.subscribe(`/topic/game/${currentGameId}/prepared`, callback);
+ watchPreparedMove(currentGameId: number): SubscribeFn<ApiPreparedCard> {
+ return this.client.subscriber(`/topic/game/${currentGameId}/prepared`);
}
- watchTurnInfo(callback: Callback<ApiPlayerTurnInfo>): void {
- return this.client.subscribe('/user/queue/game/turnInfo', callback);
+ watchTurnInfo(): SubscribeFn<ApiPlayerTurnInfo> {
+ return this.client.subscriber('/user/queue/game/turnInfo');
}
sayReady(): void {
bgstack15