Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
prom candy
Dec 16, 2005

Only I may dance

teen phone cutie posted:

listen man we get you love spotify but it's just not gonna happen no matter how much you preach it

lol I am incapable of keeping those two names separate. I do like Spotify for the record.

Adbot
ADBOT LOVES YOU

Sagacity
May 2, 2003
Hopefully my epitaph will be funnier than my custom title.

prom candy posted:

lol I am incapable of keeping those two names separate. I do like Spotify for the record.
Whereas *I* like Shopify for the shop.

prom candy
Dec 16, 2005

Only I may dance

Sagacity posted:

Whereas *I* like Shopify for the shop.

drat it

Corb3t
Jun 7, 2003

We use Shopify for all of our transactions at my new gig and it took me about a week before I stopped accidentally calling it "Spotify" half the time.

teen phone cutie
Jun 18, 2012

last year i rewrote something awful from scratch because i hate myself
does anyone have good sources for proving the point of "please god don't declare all your types in d.ts files?"

asking because I'm trying to argue for explicitly importing/exporting types in your source code, but even typescript themselves say "yeah you can do it just make sure to namespace your interfaces"

https://www.typescriptlang.org/docs/handbook/declaration-files/library-structures.html#preventing-name-conflicts

Ima Computer
Oct 28, 2007

Stop all the downloading!

Help computer.

teen phone cutie posted:

does anyone have good sources for proving the point of "please god don't declare all your types in d.ts files?"

See this question from a discussion around updating the Typescript docs for modules and the response below it from one of the devs.

I think the only good reasons to ever hand-write a .d.ts file are:

- Declaring variables in global/window scope
- Declaring types for JS-only libraries that don't have existing types (or overriding the existing types of a library)
- Declaring modules that aren't modules (declare module '*.png')

teen phone cutie
Jun 18, 2012

last year i rewrote something awful from scratch because i hate myself
perfect thank you exactly the ammo i need

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense
I'm a grandpa-aged stick in the mud and never bothered to pay attention to next.js however I'm crash coursing both it and tailwind in preparation for a job interview and am realizing that I am completely out of date on everything once again. These days we don't build servers anymore the framework we're using does that. Apparently we use React server components and we don't have to worry about nonsense like fetch requests or routing.

Oh dear lord.

Chenghiz
Feb 14, 2007

WHITE WHALE
HOLY GRAIL
i'm just waiting for the "we switched away from next.js and here's why" articles complaining about breaking changes being released every 9 months.

gbut
Mar 28, 2008

😤I put the UN🇺🇳 in 🎊FUN🎉


Nolgthorn posted:

I'm a grandpa-aged stick in the mud...

Oh dear lord.

Same. Decided to never again use React after the good ol' server components secrets leak issue. Even changed jobs so I can get as far as I can.

I'm the kind of type that gets excited about Project Gemini and similar stuff, so I guess I'm probably in the wrong thread... [*indistinguishable grumbling continues*]

prom candy
Dec 16, 2005

Only I may dance
NextJS is pushing RSCs way before they're battle tested because it helps them sell hosting. RSCs are cool and interesting but I wouldn't be using them for serious long-term work right now.

Also most web applications should probably just be a SPA. If the first thing your user sees is a login screen a SPA is probably the way to go.

abraham linksys
Sep 6, 2010

:darksouls:

prom candy posted:

If the first thing your user sees is a login screen a SPA is probably the way to go.

everything old is new again, but this is absolutely a good rule of thumb

I'm interested in RSCs at work because we have one "crossover" part of our web app that needs to serve both user needs and Google needs: our search index. Think like a Yelp search page - it's a highly-interactive UI that also needs to be rendered on the server for Google to index.

With the pages router architecture in Next (or similar "load data for this route" APIs in Remix and whatever), we could have it set up to use getServerSideProps to do the initial page load, and then have frontend logic take over for all subsequent interactions. This would require some duplication of the search logic, though, and it wouldn't be trivial to share utilities between the gSSP and client-side logic because of the different execution contexts (server and client) being so different. This is something that RSCs should theoretically solve.

In practice, I dunno if things are stable enough for us to use RSCs for this, so we probably will end up with duplication if we get around to our search frontend rewrite this year. It'd at least be better than our state-of-the-art-at-the-time Redux/Sagas home-rolled framework for SSR that currently powers our search, which while effective is really hard to work with (and almost impossible to adapt for TypeScript).

teen phone cutie
Jun 18, 2012

last year i rewrote something awful from scratch because i hate myself
begrudgingly, after taking my latest job i'm starting to think just using SPA for authed-walled apps is the way to go as well

Like, once you get over the learning curve, it's not thaaaat difficult. All your GET requests happening on the server and your POST/PUT reaching out to a backend-for-frontend route you define, so you can keep the auth token HTTP-only, and the BFF route is just a proxy endpoint. Or just using an auth library or w/e

But getting people on the same page about how that works is hard and it's probably going to be years until people get used to these new paradigms.

teen phone cutie
Jun 18, 2012

last year i rewrote something awful from scratch because i hate myself
i feel like there's this weird phenomenon happening too where even backend guys who are touching UI code are too confused by SSR frameworks and think the only point of them is for SEO.

I would have 100% expected people like that to welcome SSR back with open arms, instead of preferring single-page apps.

prom candy
Dec 16, 2005

Only I may dance
The main app I'm working on right now is Remix + Rails. It would definitely be a good candidate for SPA but it works just fine in a BFF setup as well.

abraham linksys posted:

In practice, I dunno if things are stable enough for us to use RSCs for this, so we probably will end up with duplication if we get around to our search frontend rewrite this year. It'd at least be better than our state-of-the-art-at-the-time Redux/Sagas home-rolled framework for SSR that currently powers our search, which while effective is really hard to work with (and almost impossible to adapt for TypeScript).

Just put it off until RSCs stabilize :v:

edit: or use astro

Roadie
Jun 30, 2013
There's zero reason to use RSCs at the moment. Look at the tech again once things stabilize and exist in more than just React canary branches that are entirely undocumented but that they want you to use in production anyway (???!!?!!).

prom candy
Dec 16, 2005

Only I may dance
They want you to use it in production because they want you hosting on Vercel and getting the full NextJS experience on hosts other than Vercel is not easy.

prom candy
Dec 16, 2005

Only I may dance
Some heavy hitters talking poo poo about React today on twitter

https://x.com/tannerlinsley/status/1746970043836158330?s=20

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense
I mean.

I could be a dinosaur but how I feel is that for God's sake, if servers don't exist anymore. Then basically nobody is doing anything important.

It used to be ui interfaced with something valuable. Today nothing valuable exists.

It's like midsommer where I'm waiting for some weird poo poo to take over everything. I'll be the guy in the bear skin.

Nolgthorn fucked around with this message at 02:41 on Jan 16, 2024

smackfu
Jun 7, 2004

I don’t even understand that rant.

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense
That's fair

DaWolfey
Oct 25, 2003

College Slice
I do find it perplexing what "serverless" even means - something somewhere still sends your browser the content to put on the screen, even if it's a whole load of javascript and templates and the browser builds the dom. What is that if not a server?

The browser puts things on the screen but if it's anything that isn't entirely standalone then there's a place where it sends data which gets processed and stored, and receives data from. What is that if not a server?

Do we just not call things that serves APIs a server?

smackfu
Jun 7, 2004

It’s really just “shared API server” but “serverless” sounds fancier.

prom candy
Dec 16, 2005

Only I may dance

DaWolfey posted:

I do find it perplexing what "serverless" even means - something somewhere still sends your browser the content to put on the screen, even if it's a whole load of javascript and templates and the browser builds the dom. What is that if not a server?

The browser puts things on the screen but if it's anything that isn't entirely standalone then there's a place where it sends data which gets processed and stored, and receives data from. What is that if not a server?

Do we just not call things that serves APIs a server?

Serverless doesn't mean no server. It means you personally don't have to think about a server. You just have a function that's ~* in the cloud *~ and it will scale to 0 if no one is hitting it and horizontally scale to infinity to meet demand (which also means AWS bill can scale to infinity)

DaWolfey
Oct 25, 2003

College Slice

prom candy posted:

Serverless doesn't mean no server.

mods: new thread title

hey mom its 420
May 12, 2007

I guess it means "less servers" I mean both those words are in the word

prom candy
Dec 16, 2005

Only I may dance
Wait til you find out what "edge" means (it has no universally agreed-upon meaning)

The Fool
Oct 16, 2003


All cloud stuff, serverless included, is just layers of abstraction. You're paying someone to manage everything under that abstraction so you only have to think of the stuff you care about. For severless it's just "I want this on demand compute and don't want to think about it when I'm not using it"

Surprise T Rex
Apr 9, 2008

Dinosaur Gum
as always, the cloud is just someone else's computer.

MrMoo
Sep 14, 2000

smackfu posted:

It’s really just “shared API server” but “serverless” sounds fancier.

Depends on the audience, the industry has moved on a little bit from PHP hosting from shared storage. “On demand VM” would be a more technically inclined description

abraham linksys
Sep 6, 2010

:darksouls:

MrMoo posted:

Depends on the audience, the industry has moved on a little bit from PHP hosting from shared storage. “On demand VM” would be a more technically inclined description

honestly the most cutting-edge forms of serverless stuff actually basically are shared PHP hosting; one of the promises of WebAssembly-based serverless backends is that everything is sandboxed without virtualization

i will continue to ignore serverless/edge technology until such time as my employer's backend does not live exclusively in one AWS data center, making it loving pointless for me to deploy anything but CDN assets closer to users

The Fool
Oct 16, 2003


Surprise T Rex posted:

as always, the cloud is just someone else's computer.

this is annoyingly reductive and has stopped being funny a while ago

yes, its someone else's computer...
...in a data center
...with backup power
...with monitoring
...with backups
...with load balancing
...with available bandwidth
...connected to other data centers around the world


for better or worse there are a shrinking number of workloads where there isn't a benefit from offloading all of that to someone else

Surprise T Rex
Apr 9, 2008

Dinosaur Gum
Yeah I was just being glib. I’m a backend guy in day job and everything is in the cloud now, and honestly these days I’m struggling to think of many use cases where AWS Lambda or Azure Functions isn’t the best way to host an API.

I guess RSC is just the logical endpoint of that, abstracting the serverless stuff out even further.

minato
Jun 7, 2004

cutty cain't hang, say 7-up.
Taco Defender
Serverless is really just an updated version of the ancient inetd. A "super-server" that listens on a bunch of ports for requests, and launches a specific program just-in-time to serve that request.

abraham linksys
Sep 6, 2010

:darksouls:

minato posted:

Serverless is really just an updated version of the ancient inetd. A "super-server" that listens on a bunch of ports for requests, and launches a specific program just-in-time to serve that request.

ah, a cgi bin

Wheany
Mar 17, 2006

Spinyahahahahahahahahahahahaha!

Doctor Rope
We have a lot of checkboxes that have this structure (this is Ember and handlebars)

HTML code:
<label class="btn btn-default" {{on 'click' (fn this.toggleField 'enableThing')}}>
	<input type="checkbox" checked={{this.enableThing}} {{on 'input' (fn this.toggleField 'enableThing')}}/>
	<span class='glyphicon {{if this.enableThing "glyphicon-check" "glyphicon-unchecked"}}'></span>	Enable thing
</label>	
And the toggleField method is just
JavaScript code:
@action
toggleField(name, event) {
	set(this, name, !get(this, name);
}
We use some old version of bootstrap and the label + span with glyphicon-check/glyphicon-unchecked thing is to hide the native checkboxes.

This works, but mostly by accident, because the field gets toggled 3 times. If you inspect the event in the toggleField method, you get:
  • a click event on the label
  • a click event on the input
  • an input event on the input

Is there a clean way of toggling the value just once?

Two things I tried just now:
Removing the input event handler from the checkbox. Doesn't work, now the click event gets toggled twice and the state never changes visually.

Removing the click handler from the label: This works, only the input event from the checkbox gets fired.

But: I have a feeling I have tried this before and in some cases clicking on the label doesn't work for whatever reason. Is there a reason this wouldn't work? Because I really don't like the triple-toggle, especially since certain toggles can cause some pretty heavy calculations to happen.

dupersaurus
Aug 1, 2012

Futurism was an art movement where dudes were all 'CARS ARE COOL AND THE PAST IS FOR CHUMPS. LET'S DRAW SOME CARS.'
Did you try to set the for attribute on the label to the id attribute on the input? And maybe make the label and input siblings instead of parent-child

Wheany
Mar 17, 2006

Spinyahahahahahahahahahahahaha!

Doctor Rope
I think my earlier problems might have come from either having a sibling relationship with a "for" or maybe I just used some other event type and not "input".

I have been pretty much copy-pasting the same solution everywhere once I got it working but I only recently realized what was happening.

Full Circle
Feb 20, 2008

Haven't used any of those libraries in ages, but do you just need an event.preventdefault() in the @action?

Adbot
ADBOT LOVES YOU

Ima Computer
Oct 28, 2007

Stop all the downloading!

Help computer.

Wheany posted:

Removing the click handler from the label: This works, only the input event from the checkbox gets fired.

But: I have a feeling I have tried this before and in some cases clicking on the label doesn't work for whatever reason. Is there a reason this wouldn't work? Because I really don't like the triple-toggle, especially since certain toggles can cause some pretty heavy calculations to happen.

As long as your markup creates the right association between a label and an input (which yours does) clicks on the <label> don't need to be handled - only the input. Redirecting events to the target input is one of the primary features of <label> tags.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply