Comments (4)
It's probably time to look at these initializer methods to define more clearly what they should be used for.
on_init
is called from the on_create
(which, in turn, is called from Screen.new
). I'm not really sure what the intent was for this method, to be honest. It's not inserted into a view yet, so this is a very early call in the lifecycle of a screen.
on_load
is triggered any time a screen is loaded via open
or open_tab_bar
, etc. It is fired just before actually pushing the screen onto the navigation stack or tab bar or whatever. In the split screen I just created, on_load actually fires after being added to the split screen. This is inconsistent. on_load
is primarily used for initiating the request for data.
will_appear
, on_appear
, will_disappear
, on_disappear
-- these are all directly called from the viewWillAppear(animated) (and view_will_appear
) methods, so they're a direct correlation. I use will_appear
to set up my view (although I make sure it only sets up the view once).
I think some cleanup and standardization is in order here. For one thing, I believe in some cases we're instantiating and wrapping a UINavigationController more than once during this process.
For your specific case, Mark, I think I'd build a special method for your table_data. More on that in a bit...
from promotion.
Something like this:
attr_accessor :my_attr_accessor
def on_load
# Initiate some async call
async do |data|
# Done with getting data. Set the accessor and update the table
self.my_attr_accessor = data
self.update_table_data
end
end
def my_attr_accessor
@my_attr_accessor ||= [] # only sets it to [] if nil
end
def table_data
# build table data here with self.my_attr_accessor
end
from promotion.
If you're loading the screen's view into another view (instead of using open
) it won't fire on_load
, so maybe on_init
is a better method. I'd avoid doing that in most cases, though. I've done it before and it seems to cause more problems than it solves (having a dangling view controller with an attached view). Maybe you're better at avoiding the pitfalls than I am.
from promotion.
So I eventually ended up solving it like this, not realizing before that I can send parameters that are set before any of the initialization or setup of the view are done.
@my_table_view = set_attributes MyTableScreen.new(:my_attr_accessor => []), {
backgroundColor: UIColor.clearColor
}
@parent_view.addSubview @my_table_view.view
and the table screen:
class MyTableScreen < ProMotion::SectionedTableScreen
attr_accessor :my_attr_accessor
# Do other stuff here
end
...but I still think that on_init
should be called before the table_setup
method.
from promotion.
Related Issues (20)
- Unable to position a TableView by using frame style HOT 4
- ProMotion lifecycle methods running out of order HOT 1
- Unable to add remote image to nav_bar button HOT 3
- Switching to Screen if already open HOT 2
- How to scroll TableScreen to bottom programatically? HOT 2
- Change tab_bar backgroundcolor HOT 2
- Remote images not showing on first load of Table Screen HOT 3
- use custom class for open_tab_bar HOT 1
- Image picker crashes in iOS10 HOT 1
- 'live' and 'pm_live' don't work anymore with version 4.13 HOT 10
- app delegate methods never called HOT 2
- Error can't convert CommentScreen into String (TypeError) HOT 5
- CollectionScreen crashes after reloading data HOT 1
- Cynical dependencies HOT 3
- Circular dependencies on High Sierra HOT 11
- search_text no longer works
- uninitialized constant ProMotion::UITabBarController (NameError) HOT 6
- Regression: WebScreen synchronous javascript execution
- Regression (or simply failing test): table screen `on_reuse` is not called after scrolling
- Ruby 2.6 deprecations removed in Ruby 2.7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from promotion.