0.9.14 • Published 11 years ago

monkeybars v0.9.14

Weekly downloads
1
License
-
Repository
github
Last release
11 years ago

MonkeyBars

A task based library that provides a simple structure for handling singular, sequential and parallel units of code.

The overall architecture is based off of the composite and decorator patterns. These patterns lend themselves very well to a task based library, where tasks can contain other tasks all contributing to the overall flow of an operation.

Installation

The library itself has no ties to the browser, and because of this it works both in client side & server side javascript projects. Include monkeybars.min.js for your client side projects or install using npm by running the following command from within your project:

Implementation

Simple Task

Monkeybars.Task is the simplest form of a task possible. You can override any of the methods provided (granted you must then call the prototype version of the method), but in its simplest form a task only requires the performTask method to be present. For a list of all possible methods and properties available have a look at the documentation.

Task Groups

Task groups are a great way to contain and structure both serial and async units of code. There are numerous syntax variations that you can use in order to create and add subtasks to a task group. Have a look at the group, parallel and sequence specs within the tests directory for all of the possible variations.

Extending

In some cases you may have a need for more specific functionality then what is provided with the simple, parallel and sequence task types. It is very simple to extend the base functionality of a specific task type to bake your own.

Decorators

There are three decorators (for, when and where) available for all three types of tasks(simple, parallel, and sequence). If you set a count on a task it will itterate for that count total. If you have a when method as a task attribute the task will only run when that method returns true. And if you have a while method the task will continuously run until that method returns false.

For Decorator

When Decorator

When Decorator

Documentation

Full documentation can be seen from within the docs directory of this project.

Nesting

As stated above the tasks within the library implement the composite design pattern, this simply means that all groups of tasks are themselves tasks. Tasks have the ability to have sub tasks nested within them, turning them into task groups. By default nested tasks run sequentially, unless otherwise specified. Currently the two types of task groups available are sequence and parallel (implementation examples above).

Sequential tasks run sub tasks one after another until all sub tasks complete. When all nested sub tasks are complete the complete state is passed to the task groups change method for handling.

Parallel tasks are task groups who's nested subtasks are executed side by side, executing whenever they can. Just like the sequential task group, when all sub tasks have completed the groups change method will be notified.

There is no limit to the depth of which you nest tasks, which is where the power of the library starts to become apparent. You can view a more complex example of this in the complex example within the examples directory.

Examples

Examples for the library can be found in the examples directory of this project.

0.9.14

11 years ago

0.9.13

11 years ago

0.9.12

11 years ago

0.9.11

11 years ago

0.9.10

11 years ago

0.9.9

11 years ago

0.9.8

11 years ago

0.9.7

11 years ago

0.9.6

11 years ago

0.9.5

11 years ago

0.9.4

11 years ago

0.9.3

11 years ago

0.9.2

11 years ago

0.9.1

11 years ago