File tree Expand file tree Collapse file tree 3 files changed +14
-8
lines changed Expand file tree Collapse file tree 3 files changed +14
-8
lines changed Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ import {
26
26
RegistryEvent
27
27
} from '../../model/models/socketMessage' ;
28
28
import { ComponentTypeEnum , Instance , objIsInstance } from '../../model/models/instance' ;
29
- import { InstanceLink , objIsLink , InstanceLinkPayload } from '../../model/models/instanceLink' ;
29
+ import { objIsLink , InstanceLinkPayload } from '../../model/models/instanceLink' ;
30
30
31
31
32
32
interface ObserverMap {
Original file line number Diff line number Diff line change @@ -80,13 +80,16 @@ export class ModelService {
80
80
this . storeService . removeFromState ( removedInstance ) ;
81
81
} ) ;
82
82
// TODO: after interface changes in ir we will receive a tuple of instances which are now linked
83
- this . socketService . subscribeForEvent < InstanceLinkPayload > ( EventTypeEnum . LinkAddedEvent ) . subscribe ( ( data ) => {
83
+ this . socketService . subscribeForEvent < InstanceLinkPayload > ( EventTypeEnum . LinkAddedEvent ) . subscribe ( ( data : InstanceLinkPayload ) => {
84
84
console . log ( 'received link added' , data ) ;
85
+ this . storeService . changeInstancesState ( [ data . instanceFrom , data . instanceTo ] ) ;
85
86
} ) ;
86
87
87
- this . socketService . subscribeForEvent < InstanceLinkPayload > ( EventTypeEnum . LinkStateChangedEvent ) . subscribe ( ( data ) => {
88
- console . log ( 'received link state changed' , data ) ;
89
- } ) ;
88
+ this . socketService . subscribeForEvent < InstanceLinkPayload > ( EventTypeEnum . LinkStateChangedEvent ) .
89
+ subscribe ( ( data : InstanceLinkPayload ) => {
90
+ console . log ( 'received link state changed' , data ) ;
91
+ this . storeService . changeInstancesState ( [ data . instanceFrom , data . instanceTo ] ) ;
92
+ } ) ;
90
93
}
91
94
92
95
/**
Original file line number Diff line number Diff line change @@ -139,10 +139,13 @@ export class StoreService {
139
139
* Updates the given @param instance in the state.
140
140
* The update is performed by overwriting the previously stored instance.
141
141
*/
142
- public changeInstanceState ( instance : Instance ) {
143
- const newState = StoreService . addNewInstanceToState ( this . stateUpdateSubject . value . state , instance ) ;
142
+ public changeInstancesState ( instances : Array < Instance > ) {
143
+ let newState : State ;
144
+ for ( const instance of instances ) {
145
+ newState = StoreService . addNewInstanceToState ( this . stateUpdateSubject . value . state , instance ) ;
146
+ }
144
147
// maybe calculate diff before
145
- this . stateUpdateSubject . next ( { state : newState , change : { type : Actions . CHANGE , elements : [ instance ] } } ) ;
148
+ this . stateUpdateSubject . next ( { state : newState , change : { type : Actions . CHANGE , elements : instances } } ) ;
146
149
}
147
150
148
151
/**
You can’t perform that action at this time.
0 commit comments