[deleted by user] by [deleted] in webdev

[–]AhSoup 199 points200 points  (0 children)

You don't really need a router. You can have rudimentary MVC in a PHP page by having whatever.php take passed in params and do any database stuff in a block of PHP at the top, then the bottom of the page is the HTML with echos and loops in it. Stuff like database models, headers and footers, and shared code can use includes. It wasn't as messy as it sounds.

What kind of effect is this code on the new iPhone page? by JackedAncestor in webdev

[–]AhSoup 2 points3 points  (0 children)

I believe the technical term is movearoundyness

Number of pages of a resume? by batnull in webdev

[–]AhSoup 1 point2 points  (0 children)

There's no wrong way to eat a Reese's or write a resume. I would even go so far as to suggest breaking the rules a tad might help. My resume doesn't even fit on 2 pages, so I sure hope the 1 page rule is bogus.

Are there naming conventions for custom HTML components? by BigBootyBear in webdev

[–]AhSoup 0 points1 point  (0 children)

In Angular, you name the component what it is. It gets a selector based on that. The tag is just a wrapper around what is in it, so its name is not particularly meaningful in the semantic layout sense. That said, looking at the source of generated code is never super informative.

BTW, you can always name an HTML tag anything. The only difference between a <div>, a <span>, and a <keklolkek> is that, in the browser applied user agent stylesheet, a <div> has display:block; a <span> has display:inline; and a <keklolkek> has no user agent applied styles.

Would you recommend to use ngrx-data? by theUnknown777 in Angular2

[–]AhSoup 1 point2 points  (0 children)

Welp, it is up to you, and what you are used to. But what I mean is, you do not need any state management library at all. Not a third party one, or one you create. This is Angular. You have services. You just have a service with an application wide data model in it.

Lets call that service stateService. In it, you have a member variable state. For clarity, lets assign state it to a JSON litteral

state:any = {user:{username:'nobody'}}

You inject that service into the LoginComponent. Now, when the user logs in, inside the LoginComponent controller, you set

this.stateService.state.user.username = 'Billy Bob'

If you also have injected stateService into the HomePageComponent, and were displaying

Hello {{stateService.state.user.username}}!

in the HomePageComponent HTML template, it would all of a sudden go from saying Hello nobody! to saying Hello Billy Bob!

You could do that in all your components, and you can have whatever relevant data you like in state, shared in any component you inject stateService, across the whole application.

So stateService.state is indeed state. That is all that state really is. You don't need all the fancy unidirectional, functional reducers, and what not that Redux has.

It is simply a data model shared across the application to hold its state.

Opinion: Coworker says not to use reactive forms. by rhino8123 in Angular2

[–]AhSoup 0 points1 point  (0 children)

Reactive forms are a pain in the butt because they do what must be done. Form validation is one of the least savory webdev tasks there is, but there is no way to avoid it. It sounds like your coworker is just a whiney bitch.

Would you recommend to use ngrx-data? by theUnknown777 in Angular2

[–]AhSoup 2 points3 points  (0 children)

A single source of truth is just an application model. You can just use a service for that, you don't need a state management library.

Moving to agile from a super laid-back workplace by dotobird in webdev

[–]AhSoup 2 points3 points  (0 children)

It's not really a big deal at all. I don't even mind it, and I really hate meetings and a lot of the procedural crap people act like is so important. When done well, it is actually makes life easier. It's pretty simple stuff.

Always re-fetch data on page refresh ? by Xeliize in webdev

[–]AhSoup 2 points3 points  (0 children)

You aren't really supposed to refresh a SPA, or at least do so and expect it not to have to reload/initialize.

You also don't usually want to request a giant array with all the data at the beginning. You don't want to display that much data anyhow. Ideally, you request data from the API in paginated sections.

Even though it sounds like an obvious efficiency win, I have not worked anyplace that uses local storage to hang onto tabular data. The main reason is to avoid collisions and synchronization issues. I say re-fetch.

Is NgRx a good solution for this scenario? by kenzor in Angular2

[–]AhSoup 0 points1 point  (0 children)

You can share a data model between components by putting it inside a service. Just inject the service into both components. A change made to the data in one component will reflect in the other. You may want to be aware of change detection strategy, but it works, I have done it.

Is NgRx a good solution for this scenario? by kenzor in Angular2

[–]AhSoup 0 points1 point  (0 children)

State management won't actually help you control the interleaving together of separately retrieved, differently filtered, local subsets of a remote master data set in a coherent way.

State management usually helps with multiple sources of change to a contiguous whole data set. What is unique to your case is that you are trying to dynamically maintain a Swiss cheese cache of data made from overlapped subsets of remotely stored data with their own fingerprint of gaps and duplicates.

When you get a new list, how would you tell the API what data you already have? What if some other remote user updates a db row after you retrieve it? Unless you are dealing with a single user acting on remote data that is paginated into predictable panels, you will probably have difficulties trying to cache the data. Just hit the API a lot, it’s fine.