Backbone.js Patterns and Best Practices
图书信息
| 作者 | Swarnendu De |
| 出版社 | Packt Publishing |
| ISBN | 9781783283583 |
| 出版时间 | 2014-01-24 |
| 字数 | 75.4万 |
| 分类 | 进口书,外文原版书,电脑,网络 |
读书简介
This is a stepbystep guide to design patterns, best practices, and solutions to common problems for Backbone.jsbased application development. This book is for JavaScript developers who work with Backbone.js and want to learn the best design patterns to develop complex web applications. Basic knowledge of Backbone.js and JavaScript is essential.
目录
Backbone.js Patterns and Best Practices
Table of Contents
Backbone.js Patterns and Best Practices
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers and more
Why Subscribe?
Free Access for Packt account holders
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Errata
Piracy
Questions
1. Reducing Boilerplate with Plugin Development
Basic components of Backbone.js
Using Underscore.js
Re-using code with extensions
Creating a base class
Developing plugins without extending base classes
Understanding JavaScript mixins
What is a mixin?
Creating classic mixins
Creating functional mixins
Caching mixin functions
Using curry to combine a function and arguments
Summary
2. Working with Views
Basic usage of views
Understanding the el property
Listening to view events
Displaying model data with templates
Partially updating a view
Understanding nested views
Knowing when to use subviews
Avoiding multiple DOM reflow
Re-rendering parent views
Removing parent views
Working with templates
Storing templates in an HTML file
Storing templates in a JavaScript file
Precompiling templates
Avoiding evaluation in templates
Using template helper functions
Understanding automatic model-view data binding
Using Marionette's ItemView, CollectionView, and CompositeView
ItemView
CollectionView
Working with CompositeView
Using Layout Manager
Summary
3. Working with Models
Basic usage of models
Using the defaults property
Avoiding object references in the defaults property
Data interaction with the server
Creating a model
Updating a model
Fetching a model
Deleting a model
Validating the data
Using the Backbone.Validation plugin
Configuring validation rules
Prevalidating a model with the preValidate() method
Serializing models
Understanding the relational data model
Summary
4. Working with Collections
Basic usage of collections
Performing data operations with collections
Fetching data from the server
Saving data to the server
Sorting a collection
Sorting a collection with multiple attributes
Filtering a collection
Performing basic filtering
Filtering a collection with a duplicate collection
Self-filtering with full data pointers
Understanding the collection of multiple model types
Summary
5. Routing Best Practices and Subrouting
Working with routers
Best practices for working with routers
Avoiding large functional code in route methods
Instantiating views in router methods
Using regular expressions for selective routing
Subrouting – a key to organizing complex apps
The all-in-one router
The base router
The Users module router
Summary
6. Working with Events, Sync, and Storage
Understanding custom events
A simple case study on custom events
Using an event dispatcher
Creating multiple event dispatchers
Using different event namespaces
Avoiding memory leaks with the listenTo() method
Overriding the Backbone.sync() method
Offline storage using the Backbone.LocalStorage adapter
Summary
7. Organizing Backbone Applications – Structure, Optimize, and Deploy
Understanding the application directory structure
Working with Asynchronous Module Definition
Adding Require.js to your project
Configuring dependencies
Defining a module
Creating application architecture
Managing a project directory
Organizing code with AMD
Setting up an application
Using the module pattern
Managing objects and module communication
Using the observer/PubSub pattern
Using the mediator pattern
Understanding view management
Understanding other important features
Summary
8. Unit Test, Stub, Spy, and Mock Your App
Understanding why unit testing is important
Testing with QUnit
Performing a basic test case
Understanding the QUnit module (), setup (), and teardown () methods
Testing Backbone.js components with QUnit
Using test spies, stubs, and mocks with SinonJS
Testing with spies
Testing with stubs
Testing with mocks
Difference between mocks and stubs
Summary
A. Books, Tutorials, and References
Books for reference
Tutorials
Unit testing
Other plugins and tutorials
B. Precompiling Templates on the Server Side
C. Organizing Templates with AMD and Require.js
Precompiling with the requirejs-tpl plugin
Index
- 软件需求最佳实践——SERU过程框架原理与应用(典藏版)(徐锋)
- 县域经济破局:数智化驱动县域发展新模式(刘丁蓉,华崇鑫,朱建良)
- Once Upon a Christmas (Mills & Boon Love Inspired)(Pamela Tracy)
- 不见长安(则慕)
- 数字时代的营销战略(曹虎等)
- 文治帝国:大宋300年的世运与人物【畅销书《一看就停不下来的中国史》作者重磅新书!】(艾公子)
- 赢在思维——初中化学拉分题专项集训300题(9年级+中考)(彭嘉全)
- Delphi Collected Poetical Works of John Gower (Illustrated)(John Gower)
