Skip to content

Commit

Permalink
feat: return renderer by default
Browse files Browse the repository at this point in the history
  • Loading branch information
Hsieh Chin Fan committed Sep 26, 2024
1 parent e9c6cc5 commit 5f3c69e
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/mapclay.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,13 @@ const getRendererClass = async (config) => {
})).default
}

/**
* renderTargetWithConfig.
*
* @param {HTMLElement} target -- target element for map view
* @param {Object} config -- options for map configuration
* @return {Object} renderer -- object responsible for rendering, check property "result" for details
*/
const renderTargetWithConfig = async (target, config) => {
// In case config.apply is using alias
setValueByAliases(config)
Expand All @@ -117,11 +124,10 @@ const renderTargetWithConfig = async (target, config) => {
.forEach(([key, value]) => renderer[key] = value)

// Run functions
renderer.target = target
renderer.results = []
target.renderer = renderer
// TODO Save passed arguments for each function
return renderer.run.reduce((acc, func) => acc
renderer.run.reduce((acc, func) => acc
.then(() => {
// If dependencies not success, just skip this function
if (func.depends) {
Expand Down Expand Up @@ -150,6 +156,8 @@ const renderTargetWithConfig = async (target, config) => {
})),
Promise.resolve()
)

return renderer
}
// }}}
// Render target by config {{{
Expand Down

0 comments on commit 5f3c69e

Please sign in to comment.