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
lunar detritus
May 6, 2009


Tres Burritos posted:

I started my first "real" programming job out of school 6 months ago and I was super surprised that this was a problem. However my co-workers fought to have IE 10 be the minimum. :smugbert:

IE9 here, although the 'real' minimum is IE8 because if a client complains management bends over to get it fixed.

Adbot
ADBOT LOVES YOU

lunar detritus
May 6, 2009


Munkeymon posted:

Oh dang I didn't know TS got decorators. Tell me it can make generators work interchangeably with arrays and other iterables like in Python without importing a monkey patch library and I might never bother with vanilla JS again.

Yup.
https://github.com/Microsoft/TypeScript-Handbook/blob/master/pages/Iterators%20and%20Generators.md

lunar detritus
May 6, 2009


geeves posted:

So we're just not going to bother with 1.5.5 for now, which means we'll probably be stuck with 1.3.x til the end of time.

I'd upgrade to the last 1.4.x version, chances are everything you need supports it. 1.5.x is much newer and once everything stabilizes you can upgrade again instead of having to deal with those dependencies issues.

lunar detritus
May 6, 2009


What's the best modern framework for non-SPA apps (as in server-side rendering with a touch of dynamic behaviour on the frontend, for forms and the like)? I actually like Angular 2 but in that use case it's completely useless as it really likes having total control of its templates (I found a temporary workaround using the upgrade module and downgrading ng2 components to ng1 directives but uuuugh).

lunar detritus
May 6, 2009


I doubt Rails will completely vanish, for a lot of people it still is the fastest way to get something sellable working and migrating from it only happens if it's actually needed (SoundCloud is migrating to microservices with Scala for example, but I doubt your local business has the same needs).

I would recommend learning the basics of ruby/rails just in case and then focus on something else.

EDIT: Basically you don't want to be a Rails developer, but knowing how to use it will definitely help. At least around here knowing how to use the asset pipeline and other miscellaneous rails stuff is a requisite for a lot of otherwise pure frontend jobs.

lunar detritus fucked around with this message at 21:11 on Jun 11, 2016

lunar detritus
May 6, 2009


ModeSix posted:

So having read all this and understood the drawbacks of webpack. Why would I choose webpack over say a gulp process that minifies, concats and uglyfies both js and css?

Other than because hipster trending buzzword bullshit.

Modules, but I guess there are plugins for that so... :shrug:

lunar detritus
May 6, 2009


Skandranon posted:

It's only on the way out in the sense that Angular 2 is out and looks to be an even better framework to use, if you like Angular 1. There is also a smooth upgrade path from Angular 1, and it is getting smoother as time goes on. The Angular 1 branch is going to be supported for 2 years after Angular 2 is fully out, and they may even extend that if there is enough demand.

There's a smooth upgrade path only if you used Angular 1 for a SPA. Full stack apps (Rails/Django/Whatever server-rendered views + Angular) are hosed.

lunar detritus
May 6, 2009


Skandranon posted:

How is Angular2 more of a problem doing this than Angular1? One of the big features of Angular2 is Angular Universal, which is all about doing server side rendering of Angular2 apps.

Angular Universal looks great but changing the entire infrastructure of your legacy rails app just to add support for it seems unrealistic. There are plans to support other languages / frameworks but nothing yet.

I encountered two problems when exploring upgrading to Angular 2 (and if any of you has a clean solution for them I'd very thankful):
  • You can't use your server side views directly anymore, you need to convert them to Angular 2 components and load the templates from there. Angular 1 allowed me to put an ng-app to bootstrap the app, directives where needed, etc. Angular 1 only needed templates for its directives, everything else came already rendered. Also, bye server-side routing unless you mount a different root component for each of your pages.
  • Then I thought, maybe I can hack it and run multiple angular 2 apps, one for each component I wanted to use. One dynamic dropdowns, one for carousels, etc. Very messy but it would help me upgrade bit by bit. But, it's not possible, Angular 2 bootstrap's process only runs on the first element that matches its selector. So, if a page has two dropdowns whoops, it won't work.

Both problems can be worked around but by then the effort to achieve a working (but ugly) solution just wasn't worth it. Even the Angular 2 team says "Nope, SPAs/AU or get out":

Angular Team Member posted:

server side rendering is a huge part of angular2, today with angular/universal and soon with any number of other languages (drupal, .net, etc). that said, our vision is more that you'd write an angular application (that is, not separate client and server application) and bootstrap it server side, and then boot the SPA to take over.
https://github.com/angular/angular/issues/1858#issuecomment-208001943

Angular Team Member posted:

I don't think this is going to be supported, as angular is primarily designed as a single-page application framework, and the intent is angular should control the content inside the root app element.

That said - you should have a look at the https://github.com/angular/universal project, which enables pre-rendering of angular apps on the server side.
https://github.com/angular/angular/issues/6194#issuecomment-168246552

I mean, I really like Angular 2 but I think that using it for anything but a SPA is looking for problems. Maybe my use case of using Angular as dynamic layer on top of an app is rare? I'm crossing my fingers to get a working AU solution soon but for now I ended up migrating to Angular 1.5 + Typescript. A lot of the niceties of Angular 2 without having to touch anything else.

lunar detritus
May 6, 2009


Lumpy posted:

If that's the case, then sure. I was thinking of the "modern front end " style of the backend being only exposed as an API and isn't coupled in any way to the front. I guess if your API changes though....

If your API is not versioned I'm pretty sure you're doing it wrong.

But yeah, if your frontend is a couple of views in Rails' assets folder, sure, keep everything in the same repo. If your frontend is a bonafide API client and you want to keep it that way it should have its own repo, otherwise it just breeds laziness.

EDIT: I mean laziness in the "Oh, let's just pass those values through the templating system". I mean, that's not inherently bad but it stops being a pure client. It all depends on your development process anyway.

lunar detritus fucked around with this message at 06:25 on Aug 15, 2016

lunar detritus
May 6, 2009


I just had to upgrade from Angular 2 rc.4 to rc.5 and oh god stop with the breaking changes already :negative:

lunar detritus
May 6, 2009


HaB posted:

Ionic is a great framework - but it's for mobile. On Desktop it's just gonna look weird. If you don't have an app and aren't planning on it, you don't need Ionic.It's built on top of Cordova/Phonegap - so it's basically for the express purpose of compiling to an app.

This. Ionic is basically Bootstrap for Cordova.

lunar detritus
May 6, 2009


Anyone using Typescript and Vue 2.0? The one thing I really liked about working with Angular 2 was TS so I'm hoping it's not too much of a pain to keep using TS with Vue.

lunar detritus
May 6, 2009


What's the best pattern for handling auth http services on Angular 2? They are very pushy towards Observables but I'm not sure how they would be better than a promise in that particular case (one call to server, check if true or error, done).

lunar detritus
May 6, 2009


Kekekela posted:

In case things were too stagnant, FB just published an npm replacement:

https://code.facebook.com/posts/1840075619545360

It's very very fast, it solves by default the whole "my client can't boot up this 6-month old project" problem and it's backed by Google and Facebook. It honestly does a pretty good job solving common JS development problems.

lunar detritus
May 6, 2009


IAmKale posted:

So is this the Angular way to do this? In all my time with AngularJS and Angular2, I've never come across anyone or any guide that's suggested that Components should contain as little logic as possible, and I've never seen it suggested that Services should handle all business logic. Is this another teachable moment for a team clinging to React practices, or do I just not know Angular enough and this is perfectly acceptable?

Keeping logic out of the controllers is a popular MVC programming pattern (skinny controllers fat models) and in my own experience it makes sense in Angular because that way you don't have to instantiate the whole controller to test it, services are much easier to unit test.

John Papa's Angular 1 style guide gives a much better explanation.

lunar detritus
May 6, 2009


I have some documents in a mongo database, what would be the best way to transform it into an api?

lunar detritus
May 6, 2009


Helicity posted:

Yeah, you can (and should) do that with React too. To clarify, we've been using a variation of the "ducks" pattern along with "selectors" in the duck:

https://github.com/erikras/ducks-modular-redux

Our components are pure functions, stateless (except in rare cases), and have minimal/no logic.

Typescript 2.1 is out and has async/await, object rest/spread, and keyof! We're actually at the point now where we're starting to yank Babel out of projects when we can just use Typescript compilation, and it feels good.

Oh, the duck pattern looks very interesting. The main problem my boss has with the redux way of doing things (we're using ngrx/store) is the amount of boilerplate and extra files.

I wish I could use Typescript 2.1 but Angular doesn't support it yet. I had to roll back a couple of things because of AoT breaking. :negative:

lunar detritus
May 6, 2009


VSCode is great, I have no idea how they managed to take Electron and actually make it feel responsive and good. It even boots up faster than Atom.

lunar detritus
May 6, 2009


I'm curious about state management. If you're using something like Vuex or Redux, what should go there?

For example I have an accordion component inside a sidebar that can also be collapsed. I think that the accordion's state should manage its own state since I don't really care if the items inside are open or not BUT the sidebar's state (if it's open or not) should be in the store because it's much more probable I'll use that information somewhere else. Is this more or less correct or am I missing something?

lunar detritus fucked around with this message at 17:52 on Feb 9, 2017

lunar detritus
May 6, 2009


Gildiss posted:

The only articles I had seen about Angular 2 were about breaking updates and the modules it depends upon not being stable either.
Now I just don't see anything about it.

So yes, business as usual for JS packages.

Angular 2's API was really unstable during their beta releases and RC but it has been like a rock for +6 months now.

lunar detritus
May 6, 2009


We actually switched to Angular 2 (mostly because of Ionic 2) and Vue because of Angular 1's probable demise. Vue is quite nice though.

lunar detritus
May 6, 2009


I'm having a problem with how determining what could be a component in a Rails + Vue app. The app has two dynamic sidebars, a couple of info bars, etc, and it all comes from a server-rendered html.erb. A lot of components have "inline-template" so it looks like a mess but I'm not sure moving a form outside the template where it's used makes sense. Anyone else doing this kind of mix?

lunar detritus
May 6, 2009


Pollyanna posted:

Fun MomentJS puzzler: what's the difference between

?

Without running it I bet anything weird that may be happening is because moment likes to mutate itself.

lunar detritus
May 6, 2009


ModeSix posted:

Some of this is pretty interesting, especially when you see php/rails/sql for a "front-end" job. And react-native? Uhh... that's mobile, not front-end, or is mobile considered the new front-end?

It's javascript and javascript == frontend for a lot of people, including those recruiters.

lunar detritus
May 6, 2009


Angular 24 and Vue should solve the same problems in theory but in practice they are very different.

I think I complained about this at some point in this thread but Angular 4 is completely unusable unless you want a SPA. You have to fight against the framework to make it work in an environment where Angular doesn't control the entire DOM. Vue integrates perfectly well with whatever backend framework you want to use, with pre-cooked views with erb and all that stuff.

If you do comply with what Angular 4 proposes, it's a perfectly good framework if a bit verbose compared to Vue or React.

lunar detritus
May 6, 2009


At least you have more than one job market in the entire country. :negative:

lunar detritus
May 6, 2009


Bikeshedding over rules is the worst. Install standard (or any other eslint package that doesn't allow configuring) and you're done.

lunar detritus
May 6, 2009


While I didn't get bit by that particular issue (my linter complained about defining private variables not used in the class and I went ok :shrug: ) I had to change a lot of things to make our Angular apps AoT-compatible. It's... a lot stricter about what it needs. But AoT compilation still is an optional step so I wouldn't discard Angular because of that.

lunar detritus
May 6, 2009


Why would it be a problem to use JSX in TypeScript? You can use both without any problems.

lunar detritus
May 6, 2009


I have one of those awful style questions: Should every type be explicit in Typescript or maybe allow contextual typing for the ones that can be inferred?

lunar detritus
May 6, 2009


smackfu posted:

Ahhh, Angular plus Typescript upgrade is making me feel like I know nothing. Have to actually take some training. Ugh.

Also, I definitely feel the pain of the move from a mature technology to a more cutting edge one.

Be thankful you didn't have to use it in the beta days. :negative:

lunar detritus
May 6, 2009


Angular 1.5+ (AngularJS) is really good but I wouldn't use it for a new project.

Angular (2+) is also really good but it's a monster and chances are you don't need everything it offers. It's mostly for SPAs, unlike AngularJS, Vue or React which are a lot more flexible. Typescript is loving amazing though.

lunar detritus
May 6, 2009


While using redux (or vuex, ngrx, or anything with that pattern), is there a pattern for reconstructing objects from what's in the state and adding methods to them? A (bad) example would be

JavaScript code:
event.isToday()
//vs
isEventToday(event.date)
The latter is ok if I need that computed data in only one place, but what if I need it in multiple places/components? Should I always precompute that kind of thing in the store when getting it?

lunar detritus
May 6, 2009


I have been using https://github.com/date-fns/date-fns but there's also https://github.com/moment/luxon which seems to be immutable moment.

lunar detritus
May 6, 2009


Ape Fist posted:

I've fiddled around with some very basic React stuff and yeah it's a little closer to JS I guess than Angular 2 is at this point. But honestly for someone whose still learning about programming from a not-a-pro-but-i-know-how-a-ternary-operator-and-classes-work-i-guess level ultimately it's all just more knowledge to me.

If you want to add even more alternatives to your list, Vue is a (very) nice compromise between React's pure JS approach and Angular's angular-ish one. I tend to prefer it over both when I can choose.

lunar detritus
May 6, 2009


Pollyanna posted:

IMO if you’re doing anything more complicated than conditionals and iteration in template logic you’re probably doing something wrong.

I think that's all the logic Angular and Vue let you do in their templates anyway. React is more permissive about it since you use javascript directly but I'd expect someone using it would know better.

lunar detritus
May 6, 2009


Ape Fist posted:

code:
import { FuckAngular2 } from '@angular/core';
Can someone please unfuck communication from child to parent inter-componental communication for me?

lets imagine I have a parent component, lets say:

code:
export class Parent {

private shitBalls: boolean = true;

}
How do I make the child class change the value of the shitBalls property to false? I wish I could remote into my work machine and grab the code for an example but I can't, but basically I want to change the value of a property in the parent class to false based on, say, a button click in the child component's html template.

Angular gives you Inputs and Outputs. Your child component should receive shitBalls through an input, do whatever it needs to it and then return the new value as an output event which needs to be caught by the parent component.

This tutorial by Todd Motto looks good.

lunar detritus
May 6, 2009


Vincent Valentine posted:

Dates are already native in JavaScript, there's like thirty different ways to display them, even!

I'll give you everything else but dates are the worst.

lunar detritus
May 6, 2009


Google finally confirmed what everyone already knew: AngularJS is dead(-ish).

Adbot
ADBOT LOVES YOU

lunar detritus
May 6, 2009


Ape Fist posted:

There's probably no way you're going to convince anyone to change but for the love of god try to get them to move to Angular 2.

Or Vue, which is much more friendly to hydrating server-rendered views.

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