-
-
Notifications
You must be signed in to change notification settings - Fork 550
/
comms.ts
48 lines (41 loc) · 1.5 KB
/
comms.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import { AppState } from "@nteract/types";
/**
* Returns the Jupyter comms data for a given nteract application.
*/
export const comms = (state: AppState) => state.comms;
/**
* Returns the comms models that are stored in the nteract application state.
*/
export const models = (state: AppState) => state.comms.models;
/**
* Returns the registered comm targets that are stored in the nteract application state.
*/
export const targets = (state: AppState) => state.comms.targets;
/**
* Returns the information associated with currently registered comms.
*/
export const info = (state: AppState) => state.comms.info;
/**
* Returns the model associated with a comm at a certain id.
*
* @param state The current application state
* @param { commId } The commId to get info for
*/
export const modelById = (state: AppState, { commId }: { commId: string }) =>
state.comms.models.get(commId);
/**
* Returns the handler associated with a comm target at a certain id.
*
* @param state The current application state
* @param { commId } The commId to get target for
*/
export const targetById = (state: AppState, { commId }: { commId: string }) =>
state.comms.targets.get(commId);
/**
* Returns the information associated with a comm registered at a certain id.
*
* @param state The current application state
* @param { commId } The commId to get info for
*/
export const infoById = (state: AppState, { commId }: { commId: string }) =>
state.comms.info.get(commId);