Notes on document
...
Creates a new instance of the ScreenSnippet object.
Syntax
Code Block | ||
---|---|---|
| ||
let mySnippet = new ScreenSnippet(); |
...
Code Block | ||
---|---|---|
| ||
let mySnippet = new ssf.ScreenSnippet(); |
Parameters
None.
Methods
Code Block | ||
---|---|---|
| ||
capture() |
Creates a new instance of the ScreenSnippet object.
Syntax
Code Block | ||
---|---|---|
| ||
mySnippet.capture().then(function(bitmap) { ... }); |
Parameters
none
Returns
A Promise that resolves to an ImageBitmap object with contains the captured image and type.
...
A possible idea that has been floated is to make the ScreenSnippet tool a reusable Node Module that calls to an external executable using "child_process" that could be invoked from the container. This external executable could then use StdOut to communicate with the container to provide the result of the snippet.
Code Block | ||
---|---|---|
| ||
class ScreenSnippet { capture() { return new Promise((resolve, reject) => { const childProcess = require('child_process'); const snippetToolInterop = childProcess.fork('...', [], { silent: true }); let response = false; class ScreenSnippet snippetToolInterop.on('exit', (code, signal) => { if (!response) { reject(...); } }); snippetToolInterop.on('message', message => { if (!response) { response = true; snippetToolInterop.kill(); if (message.error) { reject(...); } else { resolve(message.bitmap); } } }); }); } } module.exports = ScreenSnippet; |
Discussion points:
(From Gareth) I've assumed we have a preference for promises vs callbacks. This seems inline with modern HTML5 standards which are deprecating callbacks.
(From Gareth) We should discuss the return object for the capture method. I've currently followed the Minuet approach.