Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Binding with {} vs binding mxml (ConstantBinding) #1244

Open
mjesteve opened this issue May 12, 2024 · 5 comments
Open

Binding with {} vs binding mxml (ConstantBinding) #1244

mjesteve opened this issue May 12, 2024 · 5 comments

Comments

@mjesteve
Copy link
Contributor

I am experimenting with Binding, specifically I am trying to bind the “dataProvider” property, of a Jewel List control, with a “dataProv” property, of the mxml view; my goal is that when I update the dataProv property the dataProvider property of the list is updated.

Binding with “{}” works perfectly, but binding through “ConstantBinding” works when the bead is initialized (set strand) but never updates the list's dataProvider again.

We can observe this behavior in the “TabBarPlayGround” view of the TDJ with the first two TabBars:

1º)
<j:TabBar width="100%" className="tabBarVerticalIconItemRenderer" dataProvider="{tabBarData}">

2º)

<j:TabBar localId="tabbar2" selectedIndex="2" className="tabBarHorizontalIconItemRenderer">
	<j:beads>
		<js:ConstantBinding sourcePropertyName="tabBarData" destinationPropertyName="dataProvider"/>
	</j:beads>
</j:TabBar>
private var _tabBarData:ArrayList = new ArrayList([
				new TabBarButtonVO("Tab 1", "tab1", MaterialIconType.ACCESSIBILITY),
				new TabBarButtonVO("Tab 2", "tab2", MaterialIconType.ACCESS_ALARMS),
				new TabBarButtonVO("Tab 3", "tab3", MaterialIconType.WALLPAPER),
				new TabBarButtonVO("Tab 4", "tab4", MaterialIconType.NATURE)
			]);

[Bindable]
public function get tabBarData():ArrayList
{
	return _tabBarData;
}
public function set tabBarData(value:ArrayList):void
{
	_tabBarData = value;
}
private function updateTabBarData():void
{
	tabBarData = new ArrayList([
		new TabBarButtonVO("Other Tab 1", "tab1", MaterialIconType.MORE),
		new TabBarButtonVO("Other Tab 2", "tab2", MaterialIconType.PAGES),
		new TabBarButtonVO("Other Tab 3", "tab3", MaterialIconType.ZOOM_IN)
		]);
}

When tabBarData is updated, updateTabBarData(), changes are reflected in the first TabBar but not in the second.
Is this performance as expected? Should another bead be used?

Thx

@aharui
Copy link
Contributor

aharui commented May 13, 2024 via email

@mjesteve
Copy link
Contributor Author

The name "gives us a clue", that's what it is, but since it's the only bead I've seen used in the examples, I thought I should use this one.
I identified 2 beads that I could use, according to basic-manifest.xml, "ConstantBinding" and "SimpleBinding" but the latter didn't work for me either.
I continue investigating.

Thx.

@Harbs
Copy link
Contributor

Harbs commented May 13, 2024

Try ContainerDataBinding. That should work with nested objects.

ContainerDataBinding is my go-to binding class...

@mjesteve
Copy link
Contributor Author

I'll try it, thanks.
@Harbs, don't you have problems with "infinite bindings" when using ContainerDataBinding? #847

@Harbs
Copy link
Contributor

Harbs commented May 13, 2024

I don't think I ever came across that issue, nor did I remember that it existed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants