Constructor Summary
Public Constructor | ||
public |
Creates a new watch task instance. |
Member Summary
Public Members | ||
public |
The Browsersync instance used. |
|
public get |
The directory to watch. |
Private Members | ||
private |
|
|
private |
Timestamp of the last pull |
|
private |
The NodeId of the last push. |
|
private |
If the task is currently pulling. |
|
private |
If the task is currently pushing. |
Method Summary
Public Methods | ||
public |
handleFileChange(path: string, root: string): Promise<boolean> Handles a file change. |
|
public |
handleServerChange(readResult: ReadStream.ReadResult): Promise<boolean> Handles an atvise server change. |
|
public |
initBrowserSync(options: Object) Initializes WatchTask#browserSyncInstance. |
|
public |
printTaskError(contextMessage: string, err: Error) Prints an error that happened while handling a change. |
|
public |
run(options: Object): Promise<{serverwatcher: Watcher, fileWatcher: sane~Watcher}, Error>{serverwatcher:> Starts the file and server watchers, initializes Browsersync and registers change event handlers. |
|
public |
Starts a file watcher for the directory WatchTask#directoryToWatch. |
|
public |
Starts a watcher that watches the atvise server for changes. |
Private Methods | ||
private |
_waitForWatcher(watcher: events~Emitter): Promise<events~Emitter, Error> Waits for a watcher (which can actually be any kind of events~Emitter) to emit a "ready" event. |
Public Constructors
public constructor() source
Creates a new watch task instance. Also creates a new Browsersync instance.
Test:
Public Members
Private Members
Public Methods
public handleFileChange(path: string, root: string): Promise<boolean> source
Handles a file change.
public handleServerChange(readResult: ReadStream.ReadResult): Promise<boolean> source
Handles an atvise server change.
Params:
Name | Type | Attribute | Description |
readResult | ReadStream.ReadResult | The read result of the modification. |
public initBrowserSync(options: Object) source
Initializes WatchTask#browserSyncInstance.
Params:
Name | Type | Attribute | Description |
options | Object | The options to pass to browsersync. |
public printTaskError(contextMessage: string, err: Error) source
Prints an error that happened while handling a change.
public run(options: Object): Promise<{serverwatcher: Watcher, fileWatcher: sane~Watcher}, Error>{serverwatcher:> source
Starts the file and server watchers, initializes Browsersync and registers change event handlers.
Return:
Promise<{serverwatcher: Watcher, fileWatcher: sane~Watcher}, Error>{serverwatcher:> | Fulfilled once all watchers are set up and Browsersync was initialized. |
Test:
public startFileWatcher(): Promise<sane~Watcher, Error> source
Starts a file watcher for the directory WatchTask#directoryToWatch.
Return:
Promise<sane~Watcher, Error> | Fulfilled with the file watcher once it is ready or rejected with the error that occurred while starting the watcher. |
public startServerWatcher(): Promise<Watcher, Error> source
Starts a watcher that watches the atvise server for changes.
Private Methods
private _waitForWatcher(watcher: events~Emitter): Promise<events~Emitter, Error> source
Waits for a watcher (which can actually be any kind of events~Emitter) to emit a "ready" event.
Params:
Name | Type | Attribute | Description |
watcher | events~Emitter | The watcher to wait for. |
Return:
Promise<events~Emitter, Error> | Fulfilled with the set up watcher or rejected with the watcher error that occurred while waiting for it to get ready. |