| 
									
										
										
										
											2016-08-26 06:07:51 +03:00
										 |  |  | # Features
 | 
					
						
							| 
									
										
										
										
											2016-08-23 17:21:35 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-23 18:04:43 +03:00
										 |  |  | Features is a module that helps build _features_ out of sets of actions | 
					
						
							| 
									
										
										
										
											2016-08-24 03:36:41 +03:00
										 |  |  | apply them to objects and manage sets of features via external criteria | 
					
						
							|  |  |  | and feature-to-feature dependencies. | 
					
						
							| 
									
										
										
										
											2016-08-23 18:04:43 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ### The main entities:
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-24 03:36:41 +03:00
										 |  |  | **FeatureSet (Features)** | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ```javascript | 
					
						
							|  |  |  | var feature_set = new FeatureSet() | 
					
						
							| 
									
										
										
										
											2016-08-24 03:48:35 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // define features... | 
					
						
							|  |  |  | // ... | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // setup features... | 
					
						
							|  |  |  | feature_set | 
					
						
							|  |  |  |   .setup([ | 
					
						
							|  |  |  |     'feature-tag', | 
					
						
							|  |  |  |     //... | 
					
						
							|  |  |  |   ]) | 
					
						
							| 
									
										
										
										
											2016-08-24 03:36:41 +03:00
										 |  |  | ``` | 
					
						
							| 
									
										
										
										
											2016-08-23 18:04:43 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | XXX | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-24 03:36:41 +03:00
										 |  |  | **Feature** | 
					
						
							|  |  |  | ```javascript | 
					
						
							|  |  |  | feature_set.Feature({ | 
					
						
							|  |  |  |   tag: 'minimal_feature_example', | 
					
						
							|  |  |  | }) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | feature_set.Feature({ | 
					
						
							|  |  |  |   // documentation (optional)... | 
					
						
							|  |  |  |   title: 'Example Feature', | 
					
						
							|  |  |  |   doc: 'A feature to demo the base API...', | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   // feature unique identifier (required)... | 
					
						
							|  |  |  |   tag: 'feature_example', | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   // applicability test (optional) | 
					
						
							|  |  |  |   isApplicable: function(){ /* ... */ }, | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   // feature load priority (optional) | 
					
						
							|  |  |  |   priority: 'medium', | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   // list of feature tags to load if available (optional) | 
					
						
							|  |  |  |   suggested: [], | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   // list of feature tags required to load before this feature (optional) | 
					
						
							|  |  |  |   depends: [], | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   // Exclusive tag (optional) | 
					
						
							|  |  |  |   exclusive: 'Example feature', | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   // feature configuration (optional) | 
					
						
							|  |  |  |   config: { | 
					
						
							|  |  |  |     option: 'value', | 
					
						
							|  |  |  |     // ... | 
					
						
							|  |  |  |   }, | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   // actions (optional) | 
					
						
							|  |  |  |   actions: Actions({ | 
					
						
							|  |  |  |     // ... | 
					
						
							|  |  |  |   }) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   // action handlers (optional) | 
					
						
							|  |  |  |   handlers: [ | 
					
						
							|  |  |  |     ['action.pre', function(){ /* ... */ }], | 
					
						
							|  |  |  |     // ... | 
					
						
							|  |  |  |   ]  | 
					
						
							|  |  |  | }) | 
					
						
							|  |  |  | ``` | 
					
						
							| 
									
										
										
										
											2016-08-23 18:04:43 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-23 17:21:35 +03:00
										 |  |  | XXX | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-24 03:48:35 +03:00
										 |  |  | **Meta-features**   | 
					
						
							|  |  |  | ```javascript | 
					
						
							|  |  |  | // meta-feature... | 
					
						
							|  |  |  | feature_set.Feature('meta-feature-tag', [ | 
					
						
							|  |  |  |   'suggested-feature-tag', | 
					
						
							|  |  |  |   'other-suggested-feature-tag', | 
					
						
							|  |  |  |   // ... | 
					
						
							|  |  |  | ]) | 
					
						
							|  |  |  | ``` | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | XXX | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-23 17:21:35 +03:00
										 |  |  | <!-- vim:set ts=4 sw=4 spell : --> |