Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
garrettmoon committed Apr 14, 2017
1 parent 1718eb8 commit 9c3c5d7
Show file tree
Hide file tree
Showing 359 changed files with 66,302 additions and 0 deletions.
2 changes: 2 additions & 0 deletions docs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
_site/

11 changes: 11 additions & 0 deletions docs/404.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
id: 4oh4
title: Page Not Found
layout: default
---

# Page Not Found

Crikey! There doesn't seem to be anything here.

If you find a broken link, feel free to send a pull request. You can also let us know at [Github](https://github.com/facebook/AsyncDisplayKit/issues) so that we can fix it.
1 change: 1 addition & 0 deletions docs/CNAME
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
asyncdisplaykit.org
5 changes: 5 additions & 0 deletions docs/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
source 'https://rubygems.org'

gem 'github-pages'
gem 'rouge', '~>1.7'
gem 'jekyll', '~>3.2.0'
31 changes: 31 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# AsyncDisplayKit Documentation

We use [Jekyll](http://jekyllrb.com/) to build the site using Markdown and host it on [Github Pages](https://pages.github.com/).

### Dependencies

Github Pages uses Jekyll to host a site and Jekyll has the following dependencies.

- [Ruby](http://www.ruby-lang.org/) (version >= 2.0.0)
- [RubyGems](http://rubygems.org/) (version >= 1.3.7)
- [Bundler](http://gembundler.com/)

Mac OS X comes pre-installed with Ruby, but you may need to update RubyGems (via `gem update --system`).
Once you have RubyGems, use it to install bundler.

```sh
$ gem install bundler
$ cd gh-pages # Go to folder
$ bundle install # Might need sudo.
```

### Run Jekyll Locally

Use Jekyll to serve the website locally (by default, at `http://localhost:4000`):

```sh
$ bundle exec jekyll serve [--incremental]
$ open http://localhost:4000/
```

For more, see https://help.github.com/articles/setting-up-your-github-pages-site-locally-with-jekyll/
24 changes: 24 additions & 0 deletions docs/_config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
url: http://asyncdisplaykit.org
name: AsyncDisplayKit
relative_permalinks: false
markdown: kramdown
timezone: America/Los_Angeles
google_analytics: UA-87502907-1

safe: true
lsi: false
highlighter: rouge

defaults:
-
scope:
path: ""
type: "posts"
values:
layout: post
is_post: true

collections:
docs:
output: true
72 changes: 72 additions & 0 deletions docs/_data/nav_docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
- title: Quick Start
items:
- getting-started
- resources
- installation
- adoption-guide-2-0-beta1
- title: Core Concepts
items:
- intelligent-preloading
- containers-overview
- node-overview
- subclassing
- node-lifecycle
- faq
- title: Layout
items:
- layout2-quickstart
- automatic-layout-examples-2
- layout2-layoutspec-types
- layout2-layout-element-properties
- layout2-api-sizing
- layout-transition-api
- title: Conveniences
items:
- hit-test-slop
- batch-fetching-api
- automatic-subnode-mgmt
- inversion
- image-modification-block
- placeholder-fade-duration
- accessibility
- uicollectionviewinterop
- title: Optimizations
items:
- layer-backing
- subtree-rasterization
- synchronous-concurrency
- corner-rounding
- title: Tools
items:
- debug-tool-hit-test-visualization
- debug-tool-pixel-scaling
- debug-tool-ASRangeController
- title: Advanced Technologies
items:
- asvisibility
- asenvironment
- asrunloopqueue
- title: Node Containers
items:
- containers-asviewcontroller
- containers-asnodecontroller
- containers-astablenode
- containers-ascollectionnode
- containers-aspagernode
- title: Nodes
items:
- display-node
- cell-node
- button-node
- text-node
- image-node
- network-image-node
- video-node
- map-node
- control-node
- scroll-node
- editable-text-node
- multiplex-image-node



11 changes: 11 additions & 0 deletions docs/_docs/accessibility.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
title: Accessibility
layout: docs
permalink: /docs/accessibility.html
prevPage: placeholder-fade-duration.html
nextPage: layer-backing.html
---

Accessibility works seamlessly in ways that even UIKit doesn’t provide. When using the powerful optimization features of <a href = "layer-backing.html">Layer Backing</a> (`.layerBacked`) and <a href = "subtree-rasterization.html">Subtree Rasterization</a> (`.shouldRasterizeDescendants`), VoiceOver can access fine-grained metadata about each element. This is pretty amazing: `CALayer` doesn’t support accessibility, and rasterization reduces everything to a single flat image.

The AsyncDisplayKit team fundamentally believes in Accessibility, and invested the time to create an innovative system to make this possible with zero developer effort. As a bonus, this also allows Automated UI Testing greater access to the interface.
146 changes: 146 additions & 0 deletions docs/_docs/adoption-guide-2-0-beta1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
---
title: "Upgrading to 2.0"
layout: docs
permalink: /docs/adoption-guide-2-0-beta1.html
prevPage: adoption-guide-2-0-beta1.html
---

<ol>
<li><a href="https://usecanvas.com/htroisi/20-release-notes/1W9sFA8hIzWPco5qqCQFaf">GitHub Release Notes</a></li>
<li><a href="adoption-guide-2-0-beta1.html#getting-the-2-0-release-candidate">Getting the 2.0 Release Candidate</a></li>
<li><a href="adoption-guide-2-0-beta1.html#testing-2-0">Testing your app with 2.0</a></li>
<li><a href="adoption-guide-2-0-beta1.html#migrating-to-2-0">Migrating to 2.0</a></li>
<li><a href="adoption-guide-2-0-beta1.html#layout-api-updates">Migrating to 2.0 (Layout)</a></li>
</ol>

## Release Notes

Please read the official release notes on <a href="https://usecanvas.com/htroisi/20-release-notes/1W9sFA8hIzWPco5qqCQFaf">GitHub</a>.


## Getting the Release Candidate

Add the following to your podfile

<div class = "highlight-group">
<div class = "code">
<pre lang="objc" class="objcCode">
pod 'AsyncDisplayKit', '>= 2.0'
</pre>
</div>
</div>

then run

<div class = "highlight-group">
<div class = "code">
<pre lang="objc" class="objcCode">
pod repo update
pod update AsyncDisplayKit
</pre>
</div>
</div>

in the terminal.

## Testing 2.0

Once you have updated to 2.0, you will see many deprecation warnings. Don't worry!

These warnings are quite safe, because we have bridged all of the old APIs for you, so that you can test out the 2.0, before migrating to the new API.

If your app fails to build instead of just showing the warnings, you might have Warnings as Errors enabled for your project. You have a few options:

1. Disable deprecation warnings in the Xcode project settings
2. Disable warnings as errors in the project's build settings.
3. Disable deprecation warnings in ASDK. To do this, change `line 74` in `ASBaseDefines.h` to `# define ASDISPLAYNODE_WARN_DEPRECATED 0`

Once your app builds and runs, test it to make sure everything is working normally. If you find any problems, try adopting the new API in that area and re-test.

One key behavior change you may notice:

- ASStackLayoutSpec's `.alignItems` property default changed to `ASStackLayoutAlignItemsStretch` instead of `ASStackLayoutAlignItemsStart`. This may cause distortion in your UI.

If you still have issues, please file a GitHub issue and we'd be happy to help you out!

## Migrating to 2.0

Once your app is working, it's time to start converting!

A full API changelog from `1.9.92` to `2.0-beta.1` is available <a href="apidiff-1992-to-20beta1.html">here</a>.

#### ASDisplayNode Changes

- ASDisplayNode's `.usesImplicitHierarchyManagement` has been renamed to `.automaticallyManagesSubnodes`. The <a href = "http://asyncdisplaykit.org/docs/automatic-subnode-mgmt.html">Automatic Subnode Management</a> API has been moved out of Beta, but has a few documented [limitations]().

- ASDisplayNode's `-cancelLayoutTransitionsInProgress` has been renamed to `-cancelLayoutTransition`. The <a href = "layout-transition-api.html">Layout Transition API</a> has been moved out of Beta. Significant new functionality is planed for future dot releases.


#### Updated Interface State Callback Methods

The new method names are meant to unify the range update methods to show how they relate to each other and be a bit more self-explanatory:

- `didEnterPreloadState / didExitPreloadState`
- `didEnterDisplayState / didExitDisplayState`
- `didEnterVisibleState / didExitVisibleState`

These new methods replace the following:

- `loadStateDidChange:(BOOL)inLoadState`
- `displayStateDidChange:(BOOL)inDisplayState`
- `visibleStateDidChange:(BOOL)isVisible`

#### Collection / Table API Updates

AsyncDisplayKit's collection and table APIs have been moved from the view space (`collectionView`, `tableView`) to the node space (`collectionNode`, `tableNode`).

- Search your project for `tableView` and `collectionView`. Most, if not all, of the data source / delegate methods have new node versions.

It is important that developers using AsyncDisplayKit understand that an ASCollectionNode is backed by an ASCollectionView (a subclass of UICollectionView). ASCollectionNode runs asynchronously, so calling number -numberOfRowsInSection on the collectionNode is different than calling it on the collectionView.

For example, let's say you have an empty table. You insert `100` rows and then immediately call -tableView:numberOfRowsInSection. This will return `0` rows. If you call -waitUntilAllUpdatesAreCommitted after insertion (waits until the collectionNode synchronizes with the collectionView), you will get 100, _but_ you might block the main thread. A good developer should rarely (or never) need to use -waitUntilAllUpdatesAreCommitted. If you update the collectionNode and then need to read back immediately, you should use the collectionNode API. You shouldn't need to talk to the collectionView.

As a rule of thumb, use the collection / table node API for everything, unless the API is not available on the collectionNode.

To summarize, any `indexPath` that is passed to the `collectionView` space references data that has been synced with `ASCollectionNode`'s underlying `UICollectionView`. Conversly, any `indexPath` that is passed to the `collectionNode` space references asynchronous data that *might not yet* have been synced with ASCollectionNode's underlying `UICollectionView`. The same concepts apply to `ASTableNode`.

An exception to this is `ASTableNode`'s `-didSelectRowAtIndexPath:`, which is called in UIKit space to make sure that `indexPath` indicies reference the data in the onscreen (data that has been synced to the underlying `UICollectionView` `dataSource`).

While previous versions of the framework required the developer to be aware of the asynchronous interplay between `ASCollectionNode` and its underlying `UICollectionView`, this new API should provide better safegaurds against developer-introduced data source inconsistencies.

Other updates include:

- Deprecate `ASTableView`'s -init method. Please use `ASTableNode` instead of `ASTableView`. While this makes adopting the framework marginally more difficult to, the benefits of using ASTableNode / ASCollectionNode over their ASTableView / ASCollectionView counterparts are signficant.

- Deprecate `-beginUpdates` and `-endUpdatesAnimated:`. Please use the `-performBatchUpdates:` methods instead.

- Deprecate `-reloadDataImmediately`. Please see the header file comments for the deprecation solution.

- Moved range tuning to the `tableNode` / `collectionNode` (from the `tableView` / `collectionView`)

- `constrainedSizeForNodeAtIndexPath:` moved from the `.dataSource` to the `.delegate` to be consistent with UIKit definitions of the roles. **Note:** Make sure that you provide a delegate for any `ASTableNode`, `ASCollectionNode` or `ASPagerNodes` that use this method. Your code will silently not call your delegate method, if you do not have a delegate assigned.

- Renamed `pagerNode:constrainedSizeForNodeAtIndexPath:` to `pagerNode:constrainedSizeForNodeAtIndex:`

- collection view update validation assertions are now enabled. If you see something like `"Invalid number of items in section 2. The number of items after the update (7) must be equal to the number of items before the update (4) plus or minus the number of items inserted or removed from the section (4 inserted, 0 removed)”`, please check the data source logic. If you have any questions, reach out to us on GitHub.

Best Practices:

- Use <a href="tip-1-nodeBlocks.html">node blocks</a> if possible. These are run in parallel on a background thread, resulting in 10x performance gains.
- Use nodes to store things about your rows.
- Make sure to batch updates that need to be batched.

Resources:

- [Video](https://youtu.be/yuDqvE5n_1g) of the ASCollectionNode Behind-the-Scenes talk at Pinterest. The <a href="/static/talks/10_3_2016_ASCollectionNode_Sequence_Diagrams.pdf">diagrams</a> seen in the talk.

- PR [#2390](https://github.com/facebook/AsyncDisplayKit/pull/2390) and PR [#2381](https://github.com/facebook/AsyncDisplayKit/pull/2381) show how we converted AsyncDisplayKit's [example projects](https://github.com/facebook/AsyncDisplayKit/tree/master/examples) to conform to this new API.


#### Layout API Updates

Please read the separate <a href="layout2-conversion-guide.html">Layout 2.0 Conversion Guide</a> for an overview of the upgrades and to see how to convert your existing layout code.

#### Help us out

If we're missing something from this list, please let us know or edit this doc for us (GitHub edit link at the top of page)!
7 changes: 7 additions & 0 deletions docs/_docs/apidiff-1992-to-20beta1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
title: API Diff
layout: apidiff
permalink: /docs/apidiff-1992-to-20beta1.html
---

<iframe src="/apidiff/ASDK_API_Diff_1.9.92_to_2.0.html" style="position:fixed; top:60px; left:0px; bottom:0px; right:0px; width:100%; height:100%; border:none; margin:0; padding:0; overflow:hidden; z-index:999999;">></iframe>
9 changes: 9 additions & 0 deletions docs/_docs/appledocs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

---
title: api
layout: docs
permalink: /docs/appledocs.html
---

<p>hi</p>
<iframe src="/appledoc"></iframe>
19 changes: 19 additions & 0 deletions docs/_docs/asenvironment.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
title: ASEnvironment
layout: docs
permalink: /docs/asenvironment.html
prevPage: asvisibility.html
nextPage: asrunloopqueue.html
---

`ASEnvironment` is a performant and scalable way to enable upward and downward propagation of information throughout the node hierarchy. It stores a variety of critical “environmental” metadata, like the trait collection, interface state, hierarchy state, and more.

Any object that conforms to the `<ASEnvironment>` protocol can propagate specific states defined in an `ASEnvironmentState` up and/or down the ASEnvironment tree. To define how merges of States should happen, specific merge functions can be provided.

Compared to UIKit, this system is very efficient and one of the reasons why nodes are much lighter weight than UIViews. This is achieved by using simple structures to store data rather than creating objects. For example, `UITraitCollection` is an object, but `ASEnvironmentTraitCollection` is just a struct.

This means that whenever a node needs to query something about its environment, for example to check its [interface state](http://asyncdisplaykit.org/docs/intelligent-preloading.html#interface-state-ranges), instead of climbing the entire tree or checking all of its children, it can go to one spot and read the value that was propogated to it.

A key operating principle of ASEnvironment is to update values when new subnodes are added or removed.

ASEnvironment powers many of the most valuable features of AsyncDisplayKit. **There is no public API available at this time.**
14 changes: 14 additions & 0 deletions docs/_docs/asrunloopqueue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
title: ASRunLoopQueue
layout: docs
permalink: /docs/asrunloopqueue.html
prevPage: asenvironment.html
---

Even with main thread work, AsyncDisplayKit is able to dramatically reduce its impact on the user experience by way of the rather amazing ASRunLoopQueue.

`ASRunloopQueue` breaks up operations that must be performed on the main thread into far smaller chunks, easily 1/10th of the size that they otherwise would be, so that operation such as allocating UIViews or even destroying objects can be spread out and allow the run loops to more frequently turn. This more periodic turning allows the device to much more frequently check if a user touch has started or if an animation timer requires a new frame to be drawn, allowing far greater responsiveness even when the device is very busy and processing a large queue of main thread work.

It's a longer discussion why this kind of technique is extremely challenging to implement with `UIKit`, but it has to do with the fact that `AsyncDisplayKit` prepares content in advance, giving it a buffer of time where it can spread out the creation of these objects in tiny chunks. If it doesn't finish by the time it needs to be on screen, then it finishes the rest of what needs to be created in a single chunk. `UIKit` has no similar mechanisms to create things in advance, and there is always just one huge chunk as a view controller or cell needs to come on screen.

**ASRunLoopQueue is enabled by default when running AsyncDisplayKit.** A developer does not need to be aware of it's existence except to know that it helps reduce main thread blockage.
Loading

0 comments on commit 9c3c5d7

Please sign in to comment.