Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- option 2: component-specific object
- GridLayout Interaction State
- {
- selectedChildId: ViewerId,
- isHighlighted: boolean,
- }
- interactionManager.getAllComponents().withType('GridLayout').subscribe(
- 'onEnterPressed',
- (subscriber: { ..., interactionState: GridLayout Interaction State }, message, globalState) => {
- if (globalState.selected === subscriber.viewerId) {
- console.log('I'm the selected one!');
- interactionManager.publish({
- eventName: 'PrintSomething',
- message: { },
- });
- }
- globalState.selected = subscriber.viewerId;
- }
- );
- type ViewerHandle = {
- viewerId: ViewerId,
- parent: ViewerHandle,
- };
- type GridLayoutHandle extends ViewerHandle = {
- viewModel: {
- type: 'GridLayout',
- content: null,
- metadata: null,
- },
- selectedChildId: ViewerId,
- }
- type InteractionState = {
- };
- type InteractionManager = {
- };
- im.type().filter()
- im.forEach()
- im.type('GridLayout').forEach((viewer: ViewerHandle<GridLayout>) => {
- viewer.on('onEnterPressed', (message: Message, global: InteractionState) => {
- if (global.selectedId === viewer.viewerId) {
- im.emit('PrintSomething', {}); // (topic, message)
- }
- console.log(viewer.selectedChildId);
- });
- viewer.on('onEscPressed', (message, globalState) => {
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement