()
| 238 | declareFakeOptionallyAsyncAction(); |
| 239 | |
| 240 | const declareFakeBehaviorWithSharedData = () => { |
| 241 | const extension = new gd.PlatformExtension(); |
| 242 | extension.setExtensionInformation( |
| 243 | 'FakeBehaviorWithSharedData', |
| 244 | 'Fake behavior with shared data', |
| 245 | 'Fake behavior with shared data', |
| 246 | '', |
| 247 | 'MIT' |
| 248 | ); |
| 249 | // Declare a behavior with shared data between the behaviors |
| 250 | // In addition to the usual behavior: |
| 251 | // Create a new gd.BehaviorSharedDataJsImplementation object and implement the methods |
| 252 | // that are called to get and set the properties of the shared data. |
| 253 | const dummyBehaviorWithSharedData = new gd.BehaviorJsImplementation(); |
| 254 | // $FlowExpectedError - ignore Flow warning as we're creating a behavior |
| 255 | dummyBehaviorWithSharedData.updateProperty = function ( |
| 256 | behaviorContent, |
| 257 | propertyName, |
| 258 | newValue |
| 259 | ) { |
| 260 | if (propertyName === 'MyBehaviorProperty') { |
| 261 | behaviorContent.setStringAttribute('MyBehaviorProperty', newValue); |
| 262 | return true; |
| 263 | } |
| 264 | |
| 265 | return false; |
| 266 | }; |
| 267 | |
| 268 | dummyBehaviorWithSharedData.getProperties = function (behaviorContent) { |
| 269 | const behaviorProperties = new gd.MapStringPropertyDescriptor(); |
| 270 | |
| 271 | behaviorProperties |
| 272 | .getOrCreate('MyBehaviorProperty') |
| 273 | .setValue(behaviorContent.getStringAttribute('MyBehaviorProperty')); |
| 274 | |
| 275 | return behaviorProperties; |
| 276 | }; |
| 277 | |
| 278 | dummyBehaviorWithSharedData.initializeContent = function ( |
| 279 | behaviorContent |
| 280 | ) { |
| 281 | behaviorContent.setStringAttribute( |
| 282 | 'MyBehaviorProperty', |
| 283 | 'Initial value 1' |
| 284 | ); |
| 285 | }; |
| 286 | |
| 287 | const sharedData = new gd.BehaviorSharedDataJsImplementation(); |
| 288 | |
| 289 | sharedData.updateProperty = function ( |
| 290 | sharedContent, |
| 291 | propertyName, |
| 292 | newValue |
| 293 | ) { |
| 294 | if (propertyName === 'MySharedProperty') { |
| 295 | sharedContent.setStringAttribute('MySharedProperty', newValue); |
| 296 | return true; |
| 297 | } |
no test coverage detected