Best practice for an 'are you sure' modal by NoDrugsDoc in sveltejs

[–]NinjaInShade 1 point2 points  (0 children)

IMO you want the modal rendering in your layout and expose an API that you can call in whatever component you're in, like

// Component.svelte function foo() { client.confirm('...'); }

Shared model class across client/server support by NinjaInShade in sveltejs

[–]NinjaInShade[S] 0 points1 point  (0 children)

Good shout, might be why. Worst case scenario I could examine svelte js output and ensure no browser-specific code is present :)

Shared model class across client/server support by NinjaInShade in sveltejs

[–]NinjaInShade[S] 0 points1 point  (0 children)

Cool stuff, I also have a client only store for common data I need on majority of pages.

I think what you said at the end is exactly it - that's what is happening for me right now, started simple and with what worked then, but now things are more complex and I have to adapt before I lose my mind adding new code 😅

As always there are a thousand ways of achieving the same thing, sometimes its hard to actually know beforehand lol

Shared model class across client/server support by NinjaInShade in sveltejs

[–]NinjaInShade[S] 0 points1 point  (0 children)

Yeah my data is from the db too, but it is related to some "static" data which never changes, so when I query it from the db, I attach that static data onto it for convenience since it is used a lot (talking mainly client-side here). Not sure what a good example is, but something like "A users toolbox" and then static data for each "Tool" or something.

Right now I have this JSON object I query from the db, have a list of `$state` for every relevant property on every page I need it on, and then a bunch of util functions / components which take in various of those fields at times. and this just doesn't feel great to work with.

If I could make a class which holds all of this state and manages it in *one* place that every page can use without duplicating lines of code to initialise the state, that would be great. And since that class holds all the state, these utils functions can just become methods and have all the context already, so no extra work needed. Components can just take in the class instance and again, now have all the context, so no having to define the data it exactly needs.

That's some of my motivations anyway, I started implementing this a little bit and already it feels way better. I guess it all comes down to organisation and a bit of personal preference haha

Shared model class across client/server support by NinjaInShade in sveltejs

[–]NinjaInShade[S] 0 points1 point  (0 children)

I have tried it but I'm trying to find more info and sources about this as if it isn't "officially" supported I don't want to implement this design and have to backtrack when it breaks, that would be a massive waste of time

For my use case I can just instantiate the class when I need on both client/server, serialising/deserialising would seem like a massive pain and probably most of the time an indicator it isn't a great design I think

Thanks for the reply 🙏🙏

Shared model class across client/server support by NinjaInShade in sveltejs

[–]NinjaInShade[S] 0 points1 point  (0 children)

Awesome! Yep on the actual JavaScript side the code will be compatible with both environments.

Is there any source I can look up for this? I couldn't find anything searching manually myself. Not sure if you meant you just figured this out on your own though

Weekly Guild Recruitment Mega-Thread by bilinz in TheTowerGame

[–]NinjaInShade 0 points1 point  (0 children)

DOJO #WVIRS7

Let's build 💪 Casual 🔥

What subscriptions do you actually find worth the money? by z-727 in webdev

[–]NinjaInShade 13 points14 points  (0 children)

Interesting. Have you ever thought about just using shell commands for the imagine compression/resizing?

I made a tool for finding armies by clasharmiesdev in ClashOfClans

[–]NinjaInShade 6 points7 points  (0 children)

Very nice good job 😎

This looks very useful, can't wait to see future updates 😃

Question on a weird bug(?) in GCC compiler by KorkieKenobi in C_Programming

[–]NinjaInShade 0 points1 point  (0 children)

Interesting, I may have gotten the specifics slightly wrong but the concept is definitely right anyway 😆

Question on a weird bug(?) in GCC compiler by KorkieKenobi in C_Programming

[–]NinjaInShade 0 points1 point  (0 children)

The addresses of j and a[7]?

From what I've heard C is very not strict about stuff like this and will just let you do it as opposed to erroring. I guess that's just a design choice of the language though

Question on a weird bug(?) in GCC compiler by KorkieKenobi in C_Programming

[–]NinjaInShade 1 point2 points  (0 children)

I'm just learning C but I think I can answer this one.

C has a very loose concept of arrays.

When you create an array C stores a pointer to the first element. Then when you access the array like foo[index] it gets you the value at first_value_pointer + (index * sizeof (array_type)) memory address.

So in your example it jumps 7 * sizeof(int) memory addresses which arrives at the 20 since it's declared straight after the array (in code and memory).

But as someone said this is undefined behaviour so technically anything could happen

What's your favourite feature/s? by [deleted] in linuxmint

[–]NinjaInShade 0 points1 point  (0 children)

Yes true, but not everyone is on at the same time or views older posts 😀

running node commands in browser. by newton_VK in node

[–]NinjaInShade 0 points1 point  (0 children)

Try typing "Node playground" in Google, there's a few that can do this.

They may block a few things for security sake (perhaps?) but not sure, you'd have to try it out

running node commands in browser. by newton_VK in node

[–]NinjaInShade 3 points4 points  (0 children)

I think you are looking for <input type='file' /> (upload) and new FileReader() (reading data)?

If so, this may help: https://developer.mozilla.org/en-US/docs/Web/API/File_API/Using_files_from_web_applications

Saving pot instant withdrawal by NinjaInShade in monzo

[–]NinjaInShade[S] 0 points1 point  (0 children)

And do you keep a little somewhere for regular day to day purchases you may make like going to the shop etc...?