You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So since issue #1079 helper functions are no longer visible in the oncreate, and this is by design right? So if I have a helper function that does nothing with my state (e.g. a => a + 1) I should make it an method or move it outside my svelte component and then reference it again in the helpers section if I also need this function in my template? Just checking if I understand it right, I think it would be nice to use helpers in the oncreate, I use this for some api resolving that is also used in the template for an Oauth link.
Yep this is by design. Helper functions should always be pure (not depend on the state, not affect the state) and are intended for use in the template. The intent is that methods should have some sort of side-effect, so the preferred way to handle what you want is to move the function outside your component (you don't need to move it completely outside the file, just out of the main export default { ... }) and refer to it wherever you need it and also include it in your helpers.
I do see #1079 as definitely more of a leaky scope bug rather than a feature - the javascript in your <script> tag should be 'just javascript', with no special extra globals available to it.
So since issue #1079 helper functions are no longer visible in the
oncreate
, and this is by design right? So if I have a helper function that does nothing with my state (e.g.a => a + 1
) I should make it an method or move it outside my svelte component and then reference it again in the helpers section if I also need this function in my template? Just checking if I understand it right, I think it would be nice to use helpers in theoncreate
, I use this for some api resolving that is also used in the template for an Oauth link.See this is working in REPL 1.51.1 and failing in REPL 1.52.0.
The text was updated successfully, but these errors were encountered: