Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.
SOLVED

How to wait until two sharedproperties synchronize?

Avatar

Level 3

Hello,

Any code samples for waiting until two sharedproperties are synched? (one of them is a batonproperty as well)

I am aware I Can check if both of them are "issynchronized" and also can attach event listeners, but how do I make one wait for the other sync to finish?

1 Accepted Solution

Avatar

Correct answer by
Employee

Just throwing out a suggestion, not sure if its a neat approach.

sharedProp_1.addEventListener(CollectionNodeEvent.SYNCHRONIZATION_CHANGE, listener1)

batonProp_1.addEventListener(CollectionNodeEvent.SYNCHRONIZATION_CHANGE, listener2)

protected function listener1(evt: CollectionNodeEvent) {

    tempFunc();

}

protected function listener2(evt: CollectionNodeEvent) {

    tempFunc();

}

protected function tempFunc() {

if (sharedProp_1.isSynchronized && batonProp_1.isSynchronized) {

          //Do soemthing

     }

}

View solution in original post

2 Replies

Avatar

Correct answer by
Employee

Just throwing out a suggestion, not sure if its a neat approach.

sharedProp_1.addEventListener(CollectionNodeEvent.SYNCHRONIZATION_CHANGE, listener1)

batonProp_1.addEventListener(CollectionNodeEvent.SYNCHRONIZATION_CHANGE, listener2)

protected function listener1(evt: CollectionNodeEvent) {

    tempFunc();

}

protected function listener2(evt: CollectionNodeEvent) {

    tempFunc();

}

protected function tempFunc() {

if (sharedProp_1.isSynchronized && batonProp_1.isSynchronized) {

          //Do soemthing

     }

}