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
Forgall
Oct 16, 2012

by Azathoth

Skandranon posted:

How FAST do you need these downloads to be? Depending on how many concurrent downloads you expect, you can probably get by on just a free AWS/Azure tier system hosting a website with the files on it. Don't even really need to host the website there, just link to the files.
Don't know about Azure, but AWS free tier only lasts a year and includes 15GB of monthly bandwidth, after which you pay 9 cents per GB which is pretty pricey. VPS providers like DigitalOcean/Linode/Vultr will give you a couple terabytes per month for a tenner with 1-2 cents per GB of overage, but you have to manage your own server to ensure high availability.

Adbot
ADBOT LOVES YOU

The Fool
Oct 16, 2003


The March Hare posted:

Moderately fast, it really doesn't matter as long as people don't notice that it is incredibly slow. I figured I'd be in free tier for a while, should I just use whatever looks cheapest from AWS S3/Google Cloud/whatever Azure calls their poo poo? Or is there some kind of super special subservice within these that people use for hosting larger static files?

Thinking of a CDN?

https://docs.microsoft.com/en-us/azure/cdn/cdn-overview

or

https://aws.amazon.com/cloudfront/

Forgall posted:

Don't know about Azure, but AWS free tier only lasts a year and includes 15GB of monthly bandwidth, after which you pay 9 cents per GB which is pretty pricey. VPS providers like DigitalOcean/Linode/Vultr will give you a couple terabytes per month for a tenner with 1-2 cents per GB of overage, but you have to manage your own server to ensure high availability.

Azure has 5gb/month free outgoing bandwidth for all traffic outside of ExpressRoute and the CDN service. It's roughly $0.08/GB after that.

Azure also has a free tier and shared tier ($10/month) web app hosting that may work. https://azure.microsoft.com/en-us/pricing/details/app-service/


vvvv----- I had a dreamhost account for a long time, and while I personally never had any issues with them, I'd never host anything there that would require any sort of guaranteed up time.

The Fool fucked around with this message at 18:10 on Jun 30, 2017

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



There's always shared hosting with 'unlimited' bandwidth - I know Dreamhost does that, but I also know people seem to hate them, so :shrug:

Forgall
Oct 16, 2012

by Azathoth

The Fool posted:

Azure has 5gb/month free outgoing bandwidth for all traffic outside of ExpressRoute and the CDN service. It's roughly $0.08/GB after that.
They said 500mb files served to "a few thousand" users monthly, so let's say 5k users, 2500GB bandwidth ends up being 200 dollars at $0.08/GB, so a pretty penny...

The Fool
Oct 16, 2003


Forgall posted:

They said 500mb files served to "a few thousand" users monthly, so let's say 5k users, 2500GB bandwidth ends up being 200 dollars at $0.08/GB, so a pretty penny...

Yeah. And with the first 5gb free, they have the best bandwidth pricing of the big three.

Forgall
Oct 16, 2012

by Azathoth

The Fool posted:

Yeah. And with the first 5gb free, they have the best bandwidth pricing of the big three.
I'm just saying self-managed VPS to serve files is also an option if price is a concern.

Skandranon
Sep 6, 2008
fucking stupid, dont listen to me

The March Hare posted:

Moderately fast, it really doesn't matter as long as people don't notice that it is incredibly slow. I figured I'd be in free tier for a while, should I just use whatever looks cheapest from AWS S3/Google Cloud/whatever Azure calls their poo poo? Or is there some kind of super special subservice within these that people use for hosting larger static files?

They do have specialized file storage services, but then you are usually using their API, not just accessing an HTTP route at a friendly page. Might be worth trying, but will probably be simpler to go with some sort of mid-tier VPS provider to start with.

SurgicalOntologist
Jun 17, 2004

SurgicalOntologist posted:

I'm building the backend for a webapp (as a REST API, more or less) and I'm looking to outsource the deisgn and front-end development. It's a relatively small project, I think, for a company's internal use, no e-commerce or anything like that. It's not much more than a CRUD application. However, I'm pretty new to this and don't know where to start to get a sense of how much time and money to budget for outsourcing. I tried browsing through Upwork but that just left me more confused as to how much to budget. Anyone have any pointers on this? I'm sure you need more information to really help me out, so ask away.

Basically, what I have is a list of the different pages of the webapp, and the data each page needs to display and the functionality for interacting with it. I have the backend APIs that provide this data/functionality. And I have a logo and color scheme. I'm imagining hiring a designer to make mockups, facilitate some back-and-forth between the "client" and the designer regarding the mockups, then send the mockups and the API docs to a front-end developer. Do I have the right idea of how this could work?

I'm a data guy who taught myself enough web stuff to make an API with the functionality we need, but I don't trust myself with UX. Help me find someone to help me. And importantly, help me manage everyone else's expectations as to time and money.

Asking again. Anyone willing to exchange a few PMs to help me estimate a budget?

Skandranon
Sep 6, 2008
fucking stupid, dont listen to me

SurgicalOntologist posted:

Asking again. Anyone willing to exchange a few PMs to help me estimate a budget?

I would be fine chatting about how to estimate this, but I am already overextended in the things to do department, so could not actually do any of the work.

Space Kablooey
May 6, 2009


If it's not a problem, can you post the gist of the PMs here? I'm also interested in doing something like that.

SurgicalOntologist
Jun 17, 2004

Well, it doesn't necessarily need to go to PMs unless it starts clogging up the thread or it gets too specific. But here's an idea of the scope of the project. The website includes pages for several types of objects, a task system, a comment system, and a calendar. The backend is a well-documented API.

  • There are six different types of entities, each gets its own page with some information in a table, a pic, links to other entities, etc All populated from the backend API. One entity can be edited in a typical CRUD/REST API fashion, the rest are just read-only from the front-end.
  • There is a task system, tasks are associated with these entities and can be assigned to users. So each user's home page shows their tasks and some of the entity types will have a a create task button.
  • There is a comment system. All entities have a comment feed; which comments are shown is determined by the backend API. Most entity types will have an "add comment" button. Not a full discussion system with nested commenting.
  • There is a calendar page with several filters, read-only, events to show come from the API.
  • Login is via Google OAuth.

This doesn't seem too complicated, plus it's an internal app for small businesses so it doesn't need to be the fanciest thing. We're not trying to maximize the number of sign ups or anything, just create something with a simple enough UX that there won't be a lot of friction for this company to switch from managing their business by emailing documents around.

So... what kind of range are we looking at to outsource design and front-end development of this size of project? How much time should we expect a freelancer to take on it? Where can we cut corners to save on costs? How bad will it turn out if I just learn JavaScript and do it myself?

Our spec sheet is detailed to the point of listing what information needs to be on each page (all from the API) and what functionality it should have. Is this enough or do I need to make some first-pass mockups before hiring a designer?

If anyone wants me to get more specific in order to answer these questions, PM me, but hopefully the above description gives an idea of this size of the project. Is this a $5,000 project or a $50,000 project?

Edit: in case it's not clear, we are developing the API, I'm only asking about design and development of the front-end.

reversefungi
Nov 27, 2003

Master of the high hat!
I've only been teaching myself to code seriously for about 7 or 8 months so take what I say with a grain of salt, but that sounds relatively straightforward if I'm understanding the description correctly. The calendar could be a bit tricky depending on how you need it to look, but I'm sure you can find a module or package that can do what you need. Unless you're absolutely clueless about even the basics of HTML/CSS/basic JS, it shouldn't be that hard to throw something like bootstrap with some JS framework du jour together. If you have enough of the basics of JavaScript down (callbacks, promises, etc.) you can probably pick up React+Redux in less than 2 weeks and use that if you like. But it depends on how comfortable you are with design and things like CSS. I know lots of developers absolutely hate it and don't have much of a sense for it, so YMMV. If just thinking about the box model gives you a headache, then it might be good to find someone else. I don't know anything about pricing since I'm still a (non-professional) beginner relatively speaking, but hopefully my perspective is helpful and someone else can chime in with a range.

Since it's an internal app, I imagine you probably don't need to worry much about optimizing page load speed/supporting some ancient version of IE/etc? That will definitely start to make things more complex.

reversefungi fucked around with this message at 02:08 on Jul 2, 2017

Skandranon
Sep 6, 2008
fucking stupid, dont listen to me

SurgicalOntologist posted:


If anyone wants me to get more specific in order to answer these questions, PM me, but hopefully the above description gives an idea of this size of the project. Is this a $5,000 project or a $50,000 project?

Edit: in case it's not clear, we are developing the API, I'm only asking about design and development of the front-end.

My feeling on this is it would take me 1-2 months to do this myself, full-time. Expect to go back and forth a bit on your UX stuff, but don't let that stop you from at least trying to do mockups. So, lets say 10k - 20k. Work out your user security rules and what they can do on each screen to avoid ambiguity. You can almost certainly do a decent job on the JavaScript end yourself, you are unlikely to run into anything complicated there, but if you have a specific vision for how the UI should look, and if that matters, maybe try to get a designer to do some of the HTML/CSS for you. You can probably get just that made from some basic mockups, and then make that work in whatever framework you pick (Angular/React/Vue).

The Fool
Oct 16, 2003


Friend of mine did a similar project for a little under $20k.

The bulk of the work was done in about 3 months plus another 3 months of quibbly ux stuff.

SurgicalOntologist
Jun 17, 2004

Thanks for those responses.

For my background, I know a little HTML/CSS/JS, having put together a couple simple Flask apps. I've never used any SPA framework or anything beyond jQuery really. Most of my JS experience is from writing Bokeh callbacks (a Python plotting library that targets the web). I could do it myself for sure but I'm not sure it's the best use of my time. CSS and design is the biggest obstacle for me since my experience with that feels never got far beyond trial and error. I guess I started to get the hang of Bootstrap on my last project but the next time I have to do HTML/CSS, whether this project or a personal project, I think I'll try Semantic UI.

Skandranon posted:

My feeling on this is it would take me 1-2 months to do this myself, full-time. Expect to go back and forth a bit on your UX stuff, but don't let that stop you from at least trying to do mockups. So, lets say 10k - 20k. Work out your user security rules and what they can do on each screen to avoid ambiguity. You can almost certainly do a decent job on the JavaScript end yourself, you are unlikely to run into anything complicated there, but if you have a specific vision for how the UI should look, and if that matters, maybe try to get a designer to do some of the HTML/CSS for you. You can probably get just that made from some basic mockups, and then make that work in whatever framework you pick (Angular/React/Vue).

Here's the thing: I have no vision at all for what it should look like. Just that it should look modern and professional and be easy to use by people who might be resistant to adopting a new platform. It's not like there's a lot of functionality but it should be easily discoverable. Beyond that I don't really care. I certainly don't want to hire a design firm to "create a look for our web presence." More like I just need someone with some expertise to "arrange these elements in a way that makes sense".

So let's say I go this route: do the JS development myself but hire a designer. I don't have a good grasp on the scope of the designer's role. Is it: "here's the functionality the page should have, make me a mockup"? or more: "here's my basic minimally styled site, edit the CSS until it looks nice"? Does a designer actually produce HTML/CSS or just pass on mockups to the developer? These are things I obviously need to understand before hiring anyone. If I do it that way, how much do I need to have ready before I start talking to designers?

Actually, wow, just spending some time in the Semantic UI documentation makes me feel like I can do this myself pretty easily. I'll have to learn React (or something else) I guess but it doesn't look too hard. Maybe my best step forward is to prototype this myself, give the non-developers something to see and give feedback on, then decide whether I need more support on the design and/or development.

Based on where I seem to be at (know some JS but have never done anything requiring me to setup a local dev environment), anyone have any recommendations for learning resources? If I want to use Semantic UI, is React an OK choice for a JS framework?

Skandranon
Sep 6, 2008
fucking stupid, dont listen to me
Depends on the designer, but you should be able to get HTML/CSS out of them if you find a good one. You probably can do most of it yourself. Worth a shot. React is fine... though I am not a fan. I prefer AngularJS/Angular, but both will require some ramp up time. React is a single library for dealing with the DOM, you'll need to put together a few more to get a full SPA running. Angular comes with everything you should need to build your app. Feel free to PM me Angular questions.

Tei
Feb 19, 2011
Probation
Can't post for 6 days!
I have not followed the discussion, but design is what people give the most importance. If you make a great website with great code and amazing features, and it looks outdated. People will look bad on you. If you make a website that looks good and modern and do 100% of what is asked for but not more. People will be very happy.

Dominoes
Sep 20, 2007

If you go with React, I recommend skipping class-based components whenever possible, and using Redux immediately. (ie your state will be like a global dictionary that can only be changed explicitly; all your UI elements will reference this global state) React is nice and clean if you don't store state within the components; it gets messy fast if you try. Although you'll need to use class-comps if adding fancy functionality and input processing I can give you example code of how to get past the setup boilerplate, manage DB objects and how to put the JS into your Python file structure if you'd like. You can mirror your DB models with Redux state. If you're used to Typing/MyPy, I recommend Typescript. In addition to optional type checking, TS makes the setup quick and clean if don't need to split your code into multiple files. If you do, you need Webpack (a hot mess) to make intra-project imports work.

Dominoes fucked around with this message at 14:41 on Jul 2, 2017

Love Stole the Day
Nov 4, 2012
Please give me free quality professional advice so I can be a baby about it and insult you
Because of the positive things being said about TypeScript in this thread over the past couple of weeks, I checked it out and fell down the rabbit hole very quickly. Here's my first dumb project using it: a lovely Discord bot.

Thanks to a Packt video course, I learned how to get Visual Studio Code's Intellisense working properly and from there I felt right at home doing C++ with my terrible Unreal game jam projects. Whereas before I had been banging my head against a wall trying to figure out JavaScript's way of doing simple concepts (like structs), things like TypeScript's interfaces cause light blubs to go off in my head and my productivity has soared for the past few days.

Hopefully after I finish working on this (it's almost in a beta form so far), I'll be able to try and make a couple of bad websites in an attempt to have a portfolio for remote job seeking.

Maluco Marinero
Jan 18, 2001

Damn that's a
fine elephant.

Dominoes posted:

If you go with React, I recommend skipping class-based components whenever possible, and using Redux immediately. (ie your state will be like a global dictionary that can only be changed explicitly; all your UI elements will reference this global state) React is nice and clean if you don't store state within the components; it gets messy fast if you try. Although you'll need to use class-comps if adding fancy functionality and input processing

Gotta chime in to say steering people of internal state on a UI library feels like bad advice. If you want to make good UI, you're gonna need to keep track of more local state. The libraries out there that try to stick these interactive states into Redux end up tanking performance on keystrokes and often obscure where the data comes from.

There's nothing wrong with using React component state for forms, widgets, and so on. Redux is for shared state, and luckily most of an apps business logic data is shared, and should go into redux, but don't feel obligated to jam all the UI state into the global Redux store. Despite many people trying to force local state global like that, it's just not necessary. There's nothing wrong with containing React state locally, just don't get too fancy with it.

Dominoes
Sep 20, 2007

Maluco Marinero posted:

Gotta chime in to say steering people of internal state on a UI library feels like bad advice. If you want to make good UI, you're gonna need to keep track of more local state. The libraries out there that try to stick these interactive states into Redux end up tanking performance on keystrokes and often obscure where the data comes from.

There's nothing wrong with using React component state for forms, widgets, and so on. Redux is for shared state, and luckily most of an apps business logic data is shared, and should go into redux, but don't feel obligated to jam all the UI state into the global Redux store. Despite many people trying to force local state global like that, it's just not necessary. There's nothing wrong with containing React state locally, just don't get too fancy with it.
My perspective is thus: My input components tend to start as concise, easy-to-read functional components tied to the redux state. If I need to add something fancy, (non-standard text-handling, processing times/numbers etc, non-immediate state updating, multiple ways to set the input etc), the components quickly become a mess of OOP boilerplate. The balance between global state and component-state will vary by use-case, but React handles stateless components more elegantly.

Dominoes fucked around with this message at 16:02 on Jul 2, 2017

reversefungi
Nov 27, 2003

Master of the high hat!

SurgicalOntologist posted:

Based on where I seem to be at (know some JS but have never done anything requiring me to setup a local dev environment), anyone have any recommendations for learning resources?

I haven't done anything (yet) involving both a back end and React at the same time, but you can quickly setup a React project using create-react-app, which is as simple as can possibly be. It sets up all your boilerplate, webpack config, etc. and you should be able to get started within minutes. There's probably some extra set up to integrating it with your back end, but it shouldn't be too hard to find an article online that walks you through the extra config.

As far as learning resources go, I find the official documentation pretty helpful. The "Thinking in React" article is especially useful for getting started. If you're learning Redux too (you should), egghead.io has some good videos from the creator of Redux (Dan Abramov), so that's also worth watching.

As far as Semantic UI goes, looks like they have their own official package specifically for react, so that should be helpful!
https://react.semantic-ui.com/introduction

reversefungi fucked around with this message at 20:22 on Jul 2, 2017

Dominoes
Sep 20, 2007

The Dark Wind posted:

I haven't done anything (yet) involving both a back end and React at the same time, but you can quickly setup a React project using create-react-app, which is as simple as can possibly be. It sets up all your boilerplate, webpack config, etc. and you should be able to get started within minutes. There's probably some extra set up to integrating it with your back end, but it shouldn't be too hard to find an article online that walks you through the extra config.
This brings me to a question I'd been meaning to ask for a while: create-react-app is universally-recommended, (and there are a number of alternatives) that sets up a modern-JS config and directory structure with JSX transpiling and React included, without a backend. What's the intended use case for this? AFAIK, JS doesn't do much good without a back-end, and the config will change significantly when you incorporate one. Is it intended for use with node?

lunar detritus
May 6, 2009


Dominoes posted:

This brings me to a question I'd been meaning to ask for a while: create-react-app is universally-recommended, (and there are a number of alternatives) that sets up a modern-JS config and directory structure with JSX transpiling and React included, without a backend. What's the intended use case for this? AFAIK, JS doesn't do much good without a back-end, and the config will change significantly when you incorporate one. Is it intended for use with node?

It's probably intended to be used with an API. Same reason why many of the big "backend frameworks" are offering API-only variations (Rails, Drupal, Wordpress, etc).

Dominoes
Sep 20, 2007

gmq posted:

It's probably intended to be used with an API. Same reason why many of the big "backend frameworks" are offering API-only variations (Rails, Drupal, Wordpress, etc).
Like, link it to Django Rest with JSON?

lunar detritus
May 6, 2009


Dominoes posted:

Like, link it to Django Rest with JSON?

Yup, consume everything from an API. In most cases you end up having two apps, the backend that serves the JSON and the front app that consumes it.

Dominoes
Sep 20, 2007

Thanks. I'd like to try that sometime.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

Dominoes posted:

Thanks. I'd like to try that sometime.

I've done a couple dozen project with React and a DRF backend.

I just set up two completely distinct projects, one for the front and one for the backend. It helps make sure you've got a good design on both end.

Dominoes
Sep 20, 2007

I like the idea of it being decoupled: you could write a mobile app etc that connects to your DB, authenticates etc.

ROFLburger
Jan 12, 2006

Dominoes posted:

If you go with React, I recommend skipping class-based components whenever possible

Why?

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

Dominoes posted:

I like the idea of it being decoupled: you could write a mobile app etc that connects to your DB, authenticates etc.

Yeah thats one of the benefits. It helps you really think about the interface between your backend and your frontend. By thinking about that interface, you make it easier to add additional client types in the future.

Even if you will never need other client types, a clean interface with distinct responsibilities makes everything better.



I can't speak for him, but I always start with a stateless functions and then switch to a class only if needed because stateless function components render faster according to facebook* and are easy to test and reason about.

* AFAIK, they don't actually render faster currently, but with future React releases they will.

Thermopyle fucked around with this message at 19:25 on Jul 3, 2017

Dominoes
Sep 20, 2007

Because class-based/stated comps add boilerplate and are harder to read/write. Stateless functional comps only require the important parts. For example, I recently converted this functional comp to a stated one, after wanting some input processing:

Stateless function comp:
JavaScript code:
const SimComp = ({ sim } : {sim: Sim}) => (
        <tr>
            <td>
                <Slot job={pilotJob} person={sim.fields.pilot} item={sim}/>
            </td>

            { numSeats == 2 ? <td><Slot job={wsoJob} person={sim.fields.wso} item={sim}/></td> : null }

            <td>
                <TimeField item={sim} category={'sims'} attr={'start'} />
            </td>
            <td>
                <TimeField item={sim} category={'sims'} attr={'end'} />
            </td>
            //... etc
        </tr>
    )
Stated class-based comp:
JavaScript code:
class SimComp extends React.Component<any, any> {
    // Verbose class syntax so we can handle ASD smartly.
    constructor(props) {
        {
            super(props)
            this.state = {asd: sqConfig.fields.default_sim_asd}
        }

        this.startChange = this.startChange.bind(this)
        this.asdChange = this.asdChange.bind(this)
    }

    startChange(event) {
        this.setState({asd: event.target.value})
        const start = moment(this.props.sim.fields.start, 'HH:mm')
        const end = start.add(event.target.value, 'hours').format('HH:mm')
        changeItem(this.props.sim, 'sims', 'end', end)
    }

    asdChange(event) {
        this.setState({asd: event.target.value})
        const start = moment(this.props.sim.fields.start, 'HH:mm')
        const end = start.add(parseFloat(event.target.value), 'hours').format('HH:mm')
        changeItem(this.props.sim, 'sims', 'end', end)
    }

    render() {
        const sim: Sim = this.props.sim

        return (
            <tr>
                <td>
                    <Slot job={pilotJob} person={sim.fields.pilot} item={sim}/>
                </td>

                { numSeats == 2 ?
                    <td><Slot job={wsoJob} person={sim.fields.wso} item={sim}/>
                    </td> : null }

                <td>
                    <TimeField item={sim} category={'sims'} attr={'start'} asd={this.state.asd}/>
                </td>
                <td>
                    <input name="asd" type="number" step="0.1"
                           className="form-control" value={this.state.asd}
                           onChange={this.asdChange}/>
                </td>
                <td>
                    {/*Cut off the seconds.*/}
                    {sim.fields.end.slice(0,5)}
                </td>
		// etc
            </tr>
        )
    }
}
A good chunk of the added code is required functionality; some is boilerplate. I obviously concluded that the added functionality was worth the boilerplate.

Dominoes fucked around with this message at 20:59 on Jul 3, 2017

teen phone cutie
Jun 18, 2012

last year i rewrote something awful from scratch because i hate myself
edit: nevermind. gently caress lovely client sites

teen phone cutie fucked around with this message at 21:31 on Jul 3, 2017

ROFLburger
Jan 12, 2006

Dominoes posted:

Because class-based/stated comps add boilerplate and are harder to read/write. Stateless functional comps only require the important parts. For example, I recently converted this functional comp to a stated one, after wanting some input processing:

Stateless function comp:
JavaScript code:
...
Stated class-based comp:
JavaScript code:
....
A good chunk of the added code is required functionality; some is boilerplate. I obviously concluded that the added functionality was worth the boilerplate.

ROFLburger
Jan 12, 2006

I asked why you advised against using classes and you seem to be describing state management strategies?

Thermopyle posted:

I can't speak for him, but I always start with a stateless functions and then switch to a class only if needed because stateless function components render faster according to facebook* and are easy to test and reason about.

* AFAIK, they don't actually render faster currently, but with future React releases they will.

That's interesting, I didn't know that. A lot of people get up in arms against classes for a lot of different reasons but this is a good one.

Dominoes
Sep 20, 2007

Adding state management created the following overhead, snipped from my second example; none of this code is used to describe anything particular; it's the price of adding state to a comp. Perhaps in the future this will change, but this is how React is set up. I leave it to the reader to imagine a mockup of how stated comps could be handled to avoid this.

code:
extends React.Component {
   constructor(props) {
        {
            super(props)
            this.state = {asd: sqConfig.fields.default_sim_asd}
        }

        this.startChange = this.startChange.bind(this)
        this.asdChange = this.asdChange.bind(this)
    }

    startChange(event) {
        this.setState({asd: event.target.value})
    }

    asdChange(event) {
        this.setState({asd: event.target.value})

    }

  render() {
        const sim: Sim = this.props.sim

        return
}

Dominoes fucked around with this message at 22:28 on Jul 3, 2017

ROFLburger
Jan 12, 2006

I mean I guess I'm a little confused because I was asking you why you don't like classes. You then described separating state from presentational components which isn't something that's unique to either classes or functional components, right? Unless I'm misunderstanding something

Dominoes
Sep 20, 2007

Functional components can't have state; when you don't have internal state, they're nicer.

Lumpy
Apr 26, 2002

La! La! La! Laaaa!



College Slice

ROFLburger posted:

I mean I guess I'm a little confused because I was asking you why you don't like classes. You then described separating state from presentational components which isn't something that's unique to either classes or functional components, right? Unless I'm misunderstanding something

I'm not sure what he's going on about, but you got it. If your component has internal state, use a class-based one. If it doesn't, use a functional one, simply because they are easier to write, and at some point will get built-in rendering speed improvements.

Adbot
ADBOT LOVES YOU

darthbob88
Oct 13, 2011

YOSPOS
Stupid promise question, but is there a way to combine a possibly-null value with a promise? I currently have some code that does
code:
if (isNotNull(value)){
    doStuffWith(value);
    doMoreStuffWith(value);
} else {
    grabValueFromAPI.then(function(value) {
        doStuffWith(value); 
        doMoreStuffWith(value);
    }
}
and I would like to replace that with a single "use existing value or load from API if it doesn't exist" method, so I can avoid that code duplication. I'm trying "Promise.race([Promise.resolve(value), grabValueFromAPI])" but that's causing problems because it resolves even if value is undefined.

Worst case, I suppose I can just move that block into a single doAllTheStuffWith(value) function, but I'd rather get better at promises.

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