File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -28,6 +28,7 @@ import {
2828 CredentialedActionShape ,
2929 FilteredMetadata ,
3030 Game ,
31+ LogEntry ,
3132 PlayerID ,
3233 Reducer ,
3334 State ,
@@ -116,6 +117,14 @@ export interface ClientOpts<
116117 enhancer ?: StoreEnhancer ;
117118}
118119
120+ export type ClientState < G extends any = any > =
121+ | null
122+ | ( State < G > & {
123+ isActive : boolean ;
124+ isConnected : boolean ;
125+ log : LogEntry [ ] ;
126+ } ) ;
127+
119128/**
120129 * Implementation of Client (see below).
121130 */
@@ -359,7 +368,7 @@ export class _ClientImpl<G extends any = any> {
359368 this . manager . unregister ( this ) ;
360369 }
361370
362- subscribe ( fn : ( state : State < G > ) => void ) {
371+ subscribe ( fn : ( state : ClientState < G > ) => void ) {
363372 const id = Object . keys ( this . subscribers ) . length ;
364373 this . subscribers [ id ] = fn ;
365374 this . transport . subscribe ( ( ) => this . notifySubscribers ( ) ) ;
@@ -378,7 +387,7 @@ export class _ClientImpl<G extends any = any> {
378387 return this . initialState ;
379388 }
380389
381- getState ( ) {
390+ getState ( ) : ClientState < G > {
382391 let state = this . store . getState ( ) ;
383392
384393 if ( this . gameStateOverride !== null ) {
Original file line number Diff line number Diff line change 88
99import React from 'react' ;
1010import PropTypes from 'prop-types' ;
11- import { Client as RawClient , ClientOpts , _ClientImpl } from './client' ;
11+ import {
12+ Client as RawClient ,
13+ ClientOpts ,
14+ ClientState ,
15+ _ClientImpl ,
16+ } from './client' ;
1217
1318type WrappedBoardDelegates = 'matchID' | 'playerID' | 'credentials' ;
1419
@@ -17,7 +22,6 @@ export type WrappedBoardProps = Pick<
1722 WrappedBoardDelegates | 'debug'
1823> ;
1924
20- type ClientState < G extends any = any > = ReturnType < _ClientImpl < G > [ 'getState' ] > ;
2125type ExposedClientProps < G extends any = any > = Pick <
2226 _ClientImpl < G > ,
2327 | 'log'
You can’t perform that action at this time.
0 commit comments