-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
283 additions
and
192 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
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
51 changes: 27 additions & 24 deletions
51
packages/apps/client/src/BackendPlayground/BackendPlayground.tsx
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,27 +1,30 @@ | ||
import React, { useContext } from 'react' | ||
import { TestInterface } from '../TestInterface' | ||
import { TestPlaylists } from '../TestPlaylists' | ||
import { APIConnectionContext } from '../api/ApiConnectionContext' | ||
import { TestController } from '../TestController.tsx' | ||
import { TestViewPort } from '../TestViewPort.tsx' | ||
import React from 'react' | ||
// import { TestInterface } from '../TestInterface' | ||
// import { TestPlaylists } from '../TestPlaylists' | ||
// import { APIConnectionContext } from '../api/ApiConnectionContext' | ||
// import { TestController } from '../TestController.tsx' | ||
// import { TestViewPort } from '../TestViewPort.tsx' | ||
// import { api } from '../stores/AppStore.ts' | ||
|
||
export function BackendPlayground(): React.JSX.Element { | ||
const api = useContext(APIConnectionContext) | ||
export function BackendPlayground(): React.JSX.Element | null { | ||
// const api = useContext(APIConnectionContext) | ||
|
||
return ( | ||
<> | ||
<div> | ||
<TestInterface api={api} /> | ||
</div> | ||
<div> | ||
<TestController api={api} /> | ||
</div> | ||
<div> | ||
<TestViewPort api={api} /> | ||
</div> | ||
<div> | ||
<TestPlaylists api={api} /> | ||
</div> | ||
</> | ||
) | ||
return null | ||
|
||
// return ( | ||
// <> | ||
// <div> | ||
// <TestInterface api={api} /> | ||
// </div> | ||
// <div> | ||
// <TestController api={api} /> | ||
// </div> | ||
// <div> | ||
// <TestViewPort api={api} /> | ||
// </div> | ||
// <div> | ||
// <TestPlaylists api={api} /> | ||
// </div> | ||
// </> | ||
// ) | ||
} |
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,38 +1,38 @@ | ||
import React from 'react' | ||
import { APIConnection } from './ApiConnection' | ||
import { assertType } from '@sofie-prompter-editor/shared-lib' | ||
import { RundownPlaylist, RundownPlaylistId } from '@sofie-prompter-editor/shared-model' | ||
// import React from 'react' | ||
// import { APIConnection } from './ApiConnection' | ||
// import { assertType } from '@sofie-prompter-editor/shared-lib' | ||
// import { RundownPlaylist, RundownPlaylistId } from '@sofie-prompter-editor/shared-model' | ||
|
||
const api = new APIConnection() | ||
api.on('connected', () => console.log('connected')) | ||
api.on('disconnected', () => console.log('disconnected')) | ||
// const api = new APIConnection() | ||
// api.on('connected', () => console.log('connected')) | ||
// api.on('disconnected', () => console.log('disconnected')) | ||
|
||
api.playlist.on('tmpPong', (payload) => { | ||
assertType<string>(payload) | ||
console.log(`Got a tmpPong message: "${payload}"`) | ||
}) | ||
api.playlist.on('created', (payload) => { | ||
assertType<RundownPlaylist>(payload) | ||
console.log(`playlist created: "${JSON.stringify(payload)}"`) | ||
}) | ||
// api.playlist.on('patched', (payload) => { | ||
// assertType<Partial<RundownPlaylist>>(payload) | ||
// console.log(`playlist patched: "${JSON.stringify(payload)}"`) | ||
// api.playlist.on('tmpPong', (payload) => { | ||
// assertType<string>(payload) | ||
// console.log(`Got a tmpPong message: "${payload}"`) | ||
// }) | ||
// api.playlist.on('created', (payload) => { | ||
// assertType<RundownPlaylist>(payload) | ||
// console.log(`playlist created: "${JSON.stringify(payload)}"`) | ||
// }) | ||
// // api.playlist.on('patched', (payload) => { | ||
// // assertType<Partial<RundownPlaylist>>(payload) | ||
// // console.log(`playlist patched: "${JSON.stringify(payload)}"`) | ||
// // }) | ||
// api.playlist.on('updated', (payload) => { | ||
// assertType<RundownPlaylist>(payload) | ||
// console.log(`playlist updated: "${JSON.stringify(payload)}"`) | ||
// }) | ||
// api.playlist.on('removed', (id) => { | ||
// assertType<RundownPlaylistId>(id) | ||
// console.log(`playlist removed: "${id}"`) | ||
// }) | ||
// api.example.on('pongGeneric', (payload) => { | ||
// assertType<string>(payload) | ||
// console.log(`Got a pongGeneric message: "${payload}"`) | ||
// }) | ||
// api.example.on('pongCategory', (message) => { | ||
// console.log(`Got a pongCategory "${message.category}" message: "${message.payload}"`) | ||
// }) | ||
api.playlist.on('updated', (payload) => { | ||
assertType<RundownPlaylist>(payload) | ||
console.log(`playlist updated: "${JSON.stringify(payload)}"`) | ||
}) | ||
api.playlist.on('removed', (id) => { | ||
assertType<RundownPlaylistId>(id) | ||
console.log(`playlist removed: "${id}"`) | ||
}) | ||
api.example.on('pongGeneric', (payload) => { | ||
assertType<string>(payload) | ||
console.log(`Got a pongGeneric message: "${payload}"`) | ||
}) | ||
api.example.on('pongCategory', (message) => { | ||
console.log(`Got a pongCategory "${message.category}" message: "${message.payload}"`) | ||
}) | ||
|
||
export const APIConnectionContext = React.createContext<APIConnection>(api) | ||
// export const APIConnectionContext = React.createContext<APIConnection>(api) |
31 changes: 31 additions & 0 deletions
31
packages/apps/client/src/backendConnection/BackendConnection.ts
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,31 @@ | ||
import EventEmitter from 'eventemitter3' | ||
|
||
export type BackendConnectionEvents = { | ||
connected: [] | ||
disconnected: [] | ||
} | ||
export class BackendConnection extends EventEmitter<BackendConnectionEvents> { | ||
|
||
public readonly playlist: FeathersTypedService<PlaylistServiceDefinition.Service> | ||
|
||
constructor() { | ||
super() | ||
} | ||
|
||
// playlist = { | ||
// find: async (args?: Query<RundownPlaylist>): Promise<RundownPlaylist[]> => { | ||
// await sleep(500) | ||
// return this._playlists.filter((playlist) => !args || match(playlist, args.query)) | ||
// }, | ||
// get: async (id: RundownPlaylistId): Promise<RundownPlaylist | undefined> => { | ||
// await sleep(500) | ||
// return this._playlists.find((item) => item._id === id) | ||
// }, | ||
// on: (type: EventTypes, fn: Handler) => { | ||
// this.on(`playlist_${type}`, fn) | ||
// }, | ||
// off: (type: EventTypes, fn: Handler) => { | ||
// this.off(`playlist_${type}`, fn) | ||
// }, | ||
// } | ||
} |
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
Oops, something went wrong.