Top Related Projects
Smooth asynchronous user interfaces for iOS apps.
A data-driven UICollectionView framework for building fast and flexible lists.
A collection of iOS components.
Cocoa framework and Obj-C dynamism bindings for ReactiveSwift.
A Swift Autolayout DSL for iOS & OS X
Reactive Programming in Swift
Quick Overview
AsyncDisplayKit (now known as Texture) is a powerful iOS framework for smooth and responsive user interfaces. It enables developers to move UI work off the main thread, resulting in improved performance and responsiveness in complex iOS applications.
Pros
- Significantly improves scrolling performance and responsiveness in complex UIs
- Allows for asynchronous layout and rendering of UI elements
- Provides a declarative API for building UI components
- Integrates well with existing UIKit-based projects
Cons
- Steep learning curve for developers new to asynchronous UI programming
- Can be overkill for simple applications with basic UI requirements
- Requires careful management of threading and state to avoid race conditions
- Less active community support since Facebook archived the project (though Texture continues development)
Code Examples
- Creating a basic node:
let node = ASDisplayNode()
node.backgroundColor = .red
node.style.preferredSize = CGSize(width: 100, height: 100)
- Implementing a custom node:
class CustomNode: ASDisplayNode {
override init() {
super.init()
automaticallyManagesSubnodes = true
}
override func layout() {
super.layout()
// Custom layout logic here
}
}
- Using ASTableNode instead of UITableView:
class ViewController: ASViewController<ASTableNode> {
init() {
let tableNode = ASTableNode(style: .plain)
super.init(node: tableNode)
tableNode.dataSource = self
tableNode.delegate = self
}
// Implement ASTableDataSource and ASTableDelegate methods
}
Getting Started
To get started with AsyncDisplayKit (Texture):
-
Install via CocoaPods by adding to your Podfile:
pod 'Texture'
-
Import the framework in your Swift file:
import AsyncDisplayKit
-
Start using ASDisplayNode and its subclasses instead of UIView:
let node = ASDisplayNode() node.backgroundColor = .blue node.style.preferredSize = CGSize(width: 200, height: 200) view.addSubnode(node)
Remember to run your app on a device or use Instruments to see the performance benefits, as the simulator may not accurately represent the improvements.
Competitor Comparisons
Smooth asynchronous user interfaces for iOS apps.
Pros of Texture
- Active development and maintenance
- Improved performance and memory management
- Enhanced support for modern iOS features and Swift
Cons of Texture
- Steeper learning curve for developers new to the framework
- Some API changes may require migration efforts for existing AsyncDisplayKit projects
Code Comparison
AsyncDisplayKit:
ASDisplayNode *node = [[ASDisplayNode alloc] init];
node.backgroundColor = [UIColor redColor];
[node setNeedsLayout];
[node layoutIfNeeded];
Texture:
let node = ASDisplayNode()
node.backgroundColor = .red
node.setNeedsLayout()
node.layoutIfNeeded()
Key Differences
- Texture is the actively maintained successor to AsyncDisplayKit
- Texture offers better Swift support and integration
- AsyncDisplayKit is archived and no longer receiving updates
- Texture includes performance improvements and bug fixes
- Migration from AsyncDisplayKit to Texture may require some code changes
Conclusion
Texture is the recommended choice for new projects and those looking to upgrade from AsyncDisplayKit. While it may require some adaptation, the benefits of ongoing development, performance improvements, and better Swift support make it a superior option for most iOS developers working with asynchronous UI frameworks.
A data-driven UICollectionView framework for building fast and flexible lists.
Pros of IGListKit
- Simpler API and easier to learn, focusing specifically on UICollectionView
- Better performance for large lists with frequent updates
- More active development and community support
Cons of IGListKit
- Less flexible than AsyncDisplayKit, primarily focused on UICollectionView
- Lacks advanced layout capabilities and asynchronous rendering
- May require more manual optimization for complex UI scenarios
Code Comparison
AsyncDisplayKit (now Texture):
ASTableNode *tableNode = [[ASTableNode alloc] initWithStyle:UITableViewStylePlain];
tableNode.dataSource = self;
tableNode.delegate = self;
[self.view addSubnode:tableNode];
IGListKit:
let adapter = ListAdapter(updater: ListAdapterUpdater(), viewController: self)
adapter.collectionView = collectionView
adapter.dataSource = self
AsyncDisplayKit offers a more comprehensive approach to asynchronous UI rendering, while IGListKit focuses on optimizing UICollectionView performance. AsyncDisplayKit provides a wider range of UI components and layout options, but IGListKit excels in simplifying list management and updates.
IGListKit is generally easier to integrate into existing projects and has a gentler learning curve. However, for complex UIs with intricate layouts and animations, AsyncDisplayKit (now Texture) might offer more powerful tools and greater flexibility.
Both libraries have their strengths, and the choice between them depends on the specific requirements of your project and the complexity of your UI.
A collection of iOS components.
Pros of YYKit
- More comprehensive collection of utilities and components
- Actively maintained and updated
- Smaller footprint and easier integration for simpler projects
Cons of YYKit
- Less focused on asynchronous rendering and performance optimization
- May require more manual configuration for complex UI scenarios
- Less extensive documentation compared to AsyncDisplayKit
Code Comparison
YYKit example (image loading and caching):
UIImageView *imageView = [UIImageView new];
[imageView yy_setImageWithURL:[NSURL URLWithString:@"http://example.com/image.jpg"]
placeholder:[UIImage imageNamed:@"placeholder.png"]];
AsyncDisplayKit example (asynchronous image node):
ASNetworkImageNode *imageNode = [ASNetworkImageNode new];
imageNode.URL = [NSURL URLWithString:@"http://example.com/image.jpg"];
imageNode.defaultImage = [UIImage imageNamed:@"placeholder.png"];
Both libraries offer efficient ways to load and display images, but AsyncDisplayKit focuses more on asynchronous rendering and layout calculations, while YYKit provides a broader set of utilities for various iOS development tasks.
Cocoa framework and Obj-C dynamism bindings for ReactiveSwift.
Pros of ReactiveCocoa
- More comprehensive reactive programming framework
- Supports multiple platforms (iOS, macOS, tvOS, watchOS)
- Active community and regular updates
Cons of ReactiveCocoa
- Steeper learning curve for developers new to reactive programming
- Can lead to more complex code for simple tasks
- Potential performance overhead for small-scale applications
Code Comparison
ReactiveCocoa:
let searchResults = searchTextField.reactive.continuousTextValues
.throttle(0.3, on: QueueScheduler.main)
.flatMap(.latest) { (query: String) -> SignalProducer<[SearchResult], NoError> in
return searchAPI.search(query)
}
AsyncDisplayKit (now Texture):
- (ASCellNodeBlock)tableView:(ASTableView *)tableView nodeBlockForRowAtIndexPath:(NSIndexPath *)indexPath {
return ^{
ASTextCellNode *textCellNode = [[ASTextCellNode alloc] init];
textCellNode.text = [NSString stringWithFormat:@"Row %ld", (long)indexPath.row];
return textCellNode;
};
}
ReactiveCocoa offers a more declarative approach to handling asynchronous operations and data flow, while AsyncDisplayKit (Texture) focuses on optimizing UI performance through asynchronous display and preloading. The choice between the two depends on the specific needs of your project, with ReactiveCocoa being more suitable for complex reactive architectures and AsyncDisplayKit for high-performance UI rendering.
A Swift Autolayout DSL for iOS & OS X
Pros of SnapKit
- Lightweight and focused solely on Auto Layout
- Easy to learn and use, with a clean, expressive syntax
- Actively maintained and regularly updated
Cons of SnapKit
- Limited to Auto Layout, lacking the broader feature set of AsyncDisplayKit
- May not provide the same level of performance optimization for complex UIs
Code Comparison
SnapKit:
view.snp.makeConstraints { make in
make.top.equalTo(superview).offset(20)
make.left.right.equalTo(superview).inset(16)
make.height.equalTo(100)
}
AsyncDisplayKit:
ASDisplayNode *node = [[ASDisplayNode alloc] init];
node.style.preferredSize = CGSizeMake(100, 100);
node.style.layoutPosition = CGPointMake(16, 20);
[self.view addSubnode:node];
Summary
SnapKit is a lightweight, easy-to-use Auto Layout DSL for iOS and macOS, while AsyncDisplayKit (now Texture) is a more comprehensive UI framework focused on performance optimization. SnapKit excels in simplicity and readability for Auto Layout, while AsyncDisplayKit offers a broader range of features for building complex, high-performance user interfaces. The choice between the two depends on the specific needs of your project, with SnapKit being ideal for simpler layouts and AsyncDisplayKit better suited for more complex, performance-critical applications.
Reactive Programming in Swift
Pros of RxSwift
- Comprehensive reactive programming framework for Swift
- Extensive documentation and community support
- Seamless integration with other ReactiveX libraries
Cons of RxSwift
- Steeper learning curve for developers new to reactive programming
- Can lead to complex code if not used judiciously
- Potential performance overhead for simple use cases
Code Comparison
AsyncDisplayKit (now Texture):
let node = ASDisplayNode()
node.backgroundColor = .red
node.frame = CGRect(x: 0, y: 0, width: 100, height: 100)
view.addSubnode(node)
RxSwift:
Observable.just("Hello, RxSwift!")
.subscribe(onNext: { text in
print(text)
})
.disposed(by: disposeBag)
Key Differences
- AsyncDisplayKit focuses on asynchronous UI rendering and layout
- RxSwift is a general-purpose reactive programming framework
- AsyncDisplayKit is more specialized for high-performance UI, while RxSwift offers broader application in various programming scenarios
Use Cases
- AsyncDisplayKit: Ideal for apps with complex UIs and scrolling lists
- RxSwift: Suitable for managing asynchronous events, data streams, and reactive UI updates
Community and Maintenance
- AsyncDisplayKit (Texture) has less frequent updates but remains widely used
- RxSwift has active development and frequent releases
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
AsyncDisplayKit has been moved and renamed: Texture
Learn more here
Installation
ASDK is available via CocoaPods or Carthage. See our Installation guide for instructions.
Performance Gains
AsyncDisplayKit's basic unit is the node
. An ASDisplayNode is an abstraction over UIView
, which in turn is an abstraction over CALayer
. Unlike views, which can only be used on the main thread, nodes are thread-safe: you can instantiate and configure entire hierarchies of them in parallel on background threads.
To keep its user interface smooth and responsive, your app should render at 60 frames per second â the gold standard on iOS. This means the main thread has one-sixtieth of a second to push each frame. That's 16 milliseconds to execute all layout and drawing code! And because of system overhead, your code usually has less than ten milliseconds to run before it causes a frame drop.
AsyncDisplayKit lets you move image decoding, text sizing and rendering, layout, and other expensive UI operations off the main thread, to keep the main thread available to respond to user interaction.
Advanced Developer Features
As the framework has grown, many features have been added that can save developers tons of time by eliminating common boilerplate style structures common in modern iOS apps. If you've ever dealt with cell reuse bugs, tried to performantly preload data for a page or scroll style interface or even just tried to keep your app from dropping too many frames you can benefit from integrating ASDK.
Learn More
- Read the our Getting Started guide
- Get the sample projects
- Browse the API reference
Getting Help
We use Slack for real-time debugging, community updates, and general talk about ASDK. Signup yourself or email AsyncDisplayKit(at)gmail.com to get an invite.
Contributing
We welcome any contributions. See the CONTRIBUTING file for how to get involved.
License
AsyncDisplayKit is BSD-licensed. We also provide an additional patent grant. The files in the /examples
directory are licensed under a separate license as specified in each file; documentation is licensed CC-BY-4.0.
Top Related Projects
Smooth asynchronous user interfaces for iOS apps.
A data-driven UICollectionView framework for building fast and flexible lists.
A collection of iOS components.
Cocoa framework and Obj-C dynamism bindings for ReactiveSwift.
A Swift Autolayout DSL for iOS & OS X
Reactive Programming in Swift
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot