apache / apache/royale-asjs

By default, [Bindable] accessors / variables are not usable with BindingUtils.bindProperty()

Open
#1,012 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
ActionScript
Stars
380
Forks
120
PR merge metrics
No merged PRs in 30d

Description

In application code, doing this:

``mx.binding.utils.BindingUtils.bindProperty(targethost, "targetmember", sourcehost, ["sourcemember"]);``

where ``sourcehost.sourcemember`` is ``[Bindable]`` (with or without event name) will not produce updates of ``targethost.targetmember``.

The reason is that with the default config .xml file, the ``metadata`` showing ``'Bindable'`` is not generated in the .js file, and ChangeWatcher is expecting that info:

```
mx.binding.utils.ChangeWatcher.watch()
-> mx.binding.utils.ChangeWatcher.reset()
--> mx.binding.utils.ChangeWatcher.getEvents()
---> mx.binding.BindabilityInfo.getCachedInfo(host).getChangeEvents(name);
----> (first looking at mx.binding.BindabilityInfo.childChangeEvents[childName], otherwise looking at accessors / variables)
----> mx.binding.BindabilityInfo.addBindabilityEvents()
-----> org.apache.royale.reflection.utils.filterForMetaTags(members, ['Bindable'])
-----> mx.binding.BindabilityInfo.addChangeEvents
------> (if found, uses "valueChange" event for default [Bindable], or custom event name if specified)
```

Under ``ROYALE_REFLECTION_INFO`` in the .js file, it wants to see something like this:

`` 'text': { type: 'String', access: 'readwrite', declaredBy: 'my.awesome.company.MyClass', metadata: function () { return [ { name: 'Bindable' } ]; }},``

but it's seeing only something like this:

`` 'text': { type: 'String', access: 'readwrite', declaredBy: 'my.awesome.company.MyClass'},``

The solution is to uncomment the relevant part of the config .xml file, or use the compiler option:

``-compiler.keep-as3-metadata=Bindable``

Where is this prominently documented to help poor application developers from spending hours to figure this out?

Contributor guide

No contributing guide indexed for this repository

Research direction

Locate the default config .xml file and the existing documentation for compiler options and ROYALE_REFLECTION_INFO metadata. Document prominently that BindingUtils.bindProperty() needs Bindable metadata retained, including the relevant config setting and -compiler.keep-as3-metadata=Bindable; done means application developers can find and follow this guidance.

Written by the indexing model from the issue text.

Assessment

Domain
documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.