Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run optimize #275

Merged
merged 14 commits into from
Jun 8, 2018
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -204,13 +204,32 @@ modules.
sequencer.run();
```

Sequencer can be run with a custom progress object
Copy link
Member

@jywarren jywarren Jun 3, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just above here, where we introduce .run(), let's say:

## sequencer.run()

The `.run()` method starts the sequencer, running through each step to process the input image into a final output image. 

There are several different ways to use the `run()` function. You can pass in:

* `index` -- an `integer` - 
* `progressObj` -- an `object` used for a progress-tracking object that will be passed along the sequence (see Progress Tracking, below)
* `callback` -- a `function` to be run upon completion of the sequence

They can be used in different combinations:

`sequencer.run(index)` - run the sequencer from the given `index` starting step position

`sequencer.run(progressObj)` - 

...and so on, showing each usage separately (so not mixing `index/progressObj` in one example)

For examples of how `.run()` can be used, see [this test file demonstrating each use](...).

What do you think of this? Just really thorough, lots of examples, and link to the tests where we demonstrate it all working? The tests could be moved into a run.js test file.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jywarren this is awesome, I can do this, this is really explanatory!! Let's first complete the urlSteps PR then rebase to avoid merge conflicts later since this is on an old fork!!


```js
// The progressObj object enables custom progress bars in node environment
sequencer.run(progressObj);

```

Sequencer can also be run from a particular index(of steps array)

```js
//This runs steps only after the index(eg. 0 runs all steps)
sequencer.run(index);

```

Additionally, an optional callback can be passed to this method.

```js
sequencer.run(function(out){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's name the function function callback(out) to be extra clear. And on the line above, we can say an optional callback function. Great!!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh great Idea!!

// this gets called back.
// "out" is the DataURL of the final image.
});
sequencer.run(index/progressObj,function(out){
// the callback is supported with all types of invocations
});
```

return value: **`sequencer`** (To allow method chaining)
Expand Down