Topener / nl.fokkezb.pullToRefresh

Widget to implement a table pull-to-refresh header in Titanium Alloy
184 stars 60 forks source link

Widget stops working consistently after multiple instances of containing Controller #48

Closed caufang closed 9 years ago

caufang commented 9 years ago

I’m on iOS using Alloy.

I have an application that uses a TabGroup and in one of the tabs I am using this Widget.

When the user is logged out the TabGroup is destroyed and if they log back in a new instance of the TabGroup is started.

Any instance after the first, the ListView would most of the time not render, and no pull refresh would work either.

I tried a bunch of things and then started looking at the behavior in the widget.js file and found one small change that seems to fix the issue.

I don’t have a 100% sound reason why this works, but I think it has to do somehow with widget lifespan/scope or something.

Changing

refreshControl = Ti.UI.createRefreshControl();

to

refreshControl = $.UI.create('Ti.UI.RefreshControl');

somehow fixes the problem.

So the only thing that I can think of is that using the Ti.UI.create... method somehow is using global app scope and it’s running into some sort of issue with the RefreshControl not being able to be created again.

Whereas $.UI.create creates the RefreshControl within the scope of the Controller, in this case the Widget, and somehow that makes things work.

Again, I really have no idea why this fixes the issue as the documentation for $.UI.create doesn’t clearly explain all the differences from the Ti.UI.create... methods, but I believe that they do create using the controller styles if they are defined, so that’s what makes me think that there is some Widget “scope” at play.

This might explain the issue in #46.

FokkeZB commented 9 years ago

There's no (real) difference between $.UI.create() and Ti.UI.createX() since the first uses the latter:

I think you're dealing with https://jira.appcelerator.org/browse/TIMOB-19209

caufang commented 9 years ago

Hrm, it does seem to be related to that ticket.

Using 3.5.1 with the original code the issue doesn't come up.

Using 4.1.0 with my change the issue doesn't appear to come up.

In the commit from the ticket there was mention of a race condition, so now I'm wondering if somehow the $.ui.create method's use of eval() or all the extra steps is causing it to not collide from the race condition.

I guess i'll just compile under 3.5.1 for the time being.

FokkeZB commented 9 years ago

OK, closing as not my bug.