Function
api_register
(
api: SocketAPIData<T, U, EVENT>,
type: TYPE,
callback: Callback<EVENT, U[TYPE]>
)
Source from the content-addressed store, hash-verified
| 36 | } |
| 37 | |
| 38 | export function api_register< |
| 39 | T extends T_BASE, |
| 40 | U extends U_BASE<T>, |
| 41 | EVENT extends EVENT_BASE, |
| 42 | TYPE extends T |
| 43 | >( |
| 44 | api: SocketAPIData<T, U, EVENT>, |
| 45 | type: TYPE, |
| 46 | callback: Callback<EVENT, U[TYPE]> |
| 47 | ): void { |
| 48 | if (type in api.registered) { |
| 49 | console.warn(`Registering callback over an already used type (type: ${type}). You can ignore this message if it is intentional.`); |
| 50 | } |
| 51 | |
| 52 | api.registered[type] = callback; |
| 53 | } |
| 54 | |
| 55 | export function api_unregister< |
| 56 | T extends T_BASE, |
Tested by
no test coverage detected