-
-
Notifications
You must be signed in to change notification settings - Fork 6
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
Generalized mappings / Top-level function #13
Labels
Comments
I think another way to phrase this is that, for js/coffee mappings defined by a function, it'd be natural to think of everything as a universal dynamic symbol. This requires refactoring the "symbol cache" from individual [moved this to #50] |
edemaine
added a commit
that referenced
this issue
Aug 13, 2022
* All function mappings are now automatically dynamic; no need to wrap in a second layer of function. * Can force old static behavior (for efficiency) via `svgtiler.static` wrapper. * Support mapping defined by `Map` or `WeakMap`
edemaine
added a commit
that referenced
this issue
Aug 13, 2022
* Support mapping defined by `Map` or `WeakMap` * All function mappings are now automatically dynamic; no need to wrap in a second layer of function. * Can force old static behavior (for efficiency) via `svgtiler.static` wrapper, cached at `Mapping` level. * Function mappings get `context` second argument in addition to `this`. * `Context` object now shared throughout each drawing (so you could store extra drawing-specific data there). * API change: `Context` no longer has `symbols`, `symbol`, `data`, `filename`, or `subname` attributes. For the latter three, use `drawing.data`, `drawing.filename`, or `drawing.subname`. * API change: No more `Symbol`, `StaticSymbol`, or `DynamicSymbol` class (in particular, there was a name conflict with JS's `Symbol`) * API change: `Input` constructor supports direct loading of data (for easy manual creation) or immediate parsing of file data, as well as option setting. This will help with #34. * New `Tile` class represents an expanded (and possibly parsed) tile `<symbol>` (roughly what `Symbol` was before). * Tile caching/deduplication now within the renderer, not by `Symbol` (fix #50), enabling re-use when multiple symbols expand to the same SVG. * Fix: Don't fill in `<image>` `width`/`height` when both already set. * Fix: Use `hasOwnProperty` and `Set`s to avoid accidentally matching e.g. `toString`.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Does it make sense for top-level function to be
(key) -> -> ...@ is context...
? Why not(key) -> ...@ is context...
? Or, for that matter, just-> ...@ is context, @key is key...
?The new proposed generalized form of mapping can be
(key) -> obj[key]
),(key, context)
, and for backward compatibility, withthis
set to the context as well.This would provide backward compatibility with
-> -> ...
andX: -> ...
, but would remove the need for the double->
. It would also allow interesting/weird things likenew Mapping
takes one of the above as an argumentMapping.prototype.lookup
recursively evaluates a symbol given contextStatic Symbols
The one thing this approach would lose is a way to express static symbols defined by a function. Strings and Preact VDOM directly in an object would still be static. But I don't think functions that return things other than functions is too common in practice, because it isn't very easy. And I hope that rerunning in that case won't cost too much in performance. But I think we could replace it with:
svgtiler.static(foo)
could wrapfoo
in a declaration that its contents do not depend on context at all. This would make it easier to specify when desired for efficiency, also in a conditional or something. And it would work to specify some parts of an array are static while others are not. [This is the equivalent ofuntrack
in Solid.]context.amStatic()
would be another way within a function, but this doesn't let us distinguish individual items in an array.More broadly, fine-grained reactivity is a better solution if we want to optimize further than the static/dynamic line.
Needs to be paired with #50.
The text was updated successfully, but these errors were encountered: