Replies: 1 comment 2 replies
-
UPDATEExchanging @paoloricciuti may I trouble you for ideas? Or perhaps this would be a good feature request? |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I have a couple functions in a project at work that impersonate or stop impersonation of users. These are called from a couple of places, so I figured I wanted them centralized. DRY principle. The twist: The functions trigger user interface. Specifically, while the HTTP request takes place, an overlay appears on screen telling the user what's happening. I want this also encapsulated in the reusable module.
I decided to go the snippet route.
The whole thing is more convoluted than what I'll show, but basically there's a store that holds the piece of UI (the snippet) that the dev wants to show:
An Overlay component reactively shows or hides based on this store's
ui
property.The
impersonate()
function takes the user as parameter, simplified as a string below:The code has a line with a comment that shows the problem: Evaluating the snippet does not produce a snippet assignable to
Snippet
.In Svelte, snippets are functions that return an object with specific caracteristics. So my attempt was to use bind:
The above, in runtime throws the error "user is not a function". This is probably because I'm binding the
this
pointer incorrectly.Does anybody know how to do this?
What I'm trying to do is the snippet equivalent of
() => someFunc(args)
: Create a parameterless snippet out of one with parameters.Beta Was this translation helpful? Give feedback.
All reactions