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
Making canvasFunction() async #8027
Comments
I agree that the const source = new ImageCanvas({
canvasFunction: (extent, res, pixelRatio, size, proj) => {
source.setLoader(callback => {
myAsyncCanvasFunction(ext, res, pixelRatio, size, proj)
.then(result => {
source.setCanvas(result);
callback()
})
.catch(e => callback(e));
});
}
}); |
@ahocevar I'm not sure I understood your example. My code was the implementation of the ImageCanvas side. The API would simply allow user's Current usage: const source = new ImageCanvas({
canvasFunction: (...) => { return myCanvas; } // synchronous usage
} New capabilities: const source = new ImageCanvas({
// Asynchronous usage - returns a promise
canvasFunction: (...) => {
return new Promise((accept) => {
accept(myCanvas)
});
}
} const source = new ImageCanvas({
// Asynchronous usage - returns an observable object
canvasFunction: (...) => ({
subscribe: (o) => {
// user calls o.next(myCanvas) as often as needed to refresh
}
})
} Basically with promise it's a OL-initiated, async request for canvas, and with observable, OL subscribes to a stream of canvas updates initiated by the user. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
The
ImageCanvas.canvasFunction
is synchronous, making it cumbersome to work with in async environment. I think it would be great to allow consumers to returnobservable
andthenable
objects in addition to pure canvas. TheImageCanvas
implementation should function as follows:ol-debug.js
, notol.js
) that shows the issue.The text was updated successfully, but these errors were encountered: