|
Osmosisch posted:The nice thing about lodash is that it lets you do all this stuff without worrying about which browser/platform you're targeting too much. Thats (one of) the nice thing about transpiling too.
|
# ? Sep 6, 2017 14:44 |
|
|
# ? May 16, 2024 17:50 |
|
What's a solid place to learn the MERN stack, given I'm already pretty good with React?
|
# ? Sep 6, 2017 19:44 |
|
Got another "I should really know this by now" javascript question. See this code:code:
code:
|
# ? Sep 6, 2017 20:07 |
|
Grump posted:What's a solid place to learn the MERN stack, given I'm already pretty good with React? Unless its for a particular job or something, I wouldn't bother since MongoDB is poo poo.
|
# ? Sep 6, 2017 20:17 |
|
Knifegrab posted:Got another "I should really know this by now" javascript question. See this code: If it is called from the class, yes. If the callback is called from another context, 'this' changes. You used an arrow function in the timeout, so that is safe. However, if the object itself is GCed, and then your timeout function tries to run, it would not be able to access this.term.
|
# ? Sep 6, 2017 20:19 |
|
Thermopyle posted:Unless its for a particular job or something, I wouldn't bother since MongoDB is poo poo. Yeah i see a lot of jobs that require node experience, so i figured learning that stack together might be helpful. Are there better alternatives? I was so bored at work today I ran through a basic Java tutorial. I need something to learn
|
# ? Sep 6, 2017 20:26 |
|
Skandranon posted:If it is called from the class, yes. If the callback is called from another context, 'this' changes. You used an arrow function in the timeout, so that is safe. However, if the object itself is GCed, and then your timeout function tries to run, it would not be able to access this.term. code:
|
# ? Sep 6, 2017 20:26 |
|
Knifegrab posted:I thought because the function I am defining is defined inside the class it implicitely gets "this" of the whole class. I may be loving up scope again... Member functions don't auto-bind to the object instance. The class syntax sugar is an elaborate trap made to make you think otherwise, so don't feel too bad about it.
|
# ? Sep 6, 2017 20:27 |
|
Maybe try this?:code:
code:
reversefungi fucked around with this message at 20:32 on Sep 6, 2017 |
# ? Sep 6, 2017 20:28 |
|
IAmKale posted:I think this can be fixed with a second arrow function when calling on(): This will not work since I need a constant reference to the initial function for when I remove that listener at a later point in time. I realize now my mistake, I was not considering where it would be called. Thanks all for the clarification. The Dark Wind posted:
This is the solution I came up with as well and appears to work. Thanks all for the help. I swear context will forever be the death of me. That and socket.io's terrible documentation.
|
# ? Sep 6, 2017 20:34 |
|
Grump posted:Yeah i see a lot of jobs that require node experience, so i figured learning that stack together might be helpful. There's not much to learning node if you already know JS and used to installing npm packages. If you're interested, I'd just look up some tutorials on Express. For a backend database you can't go wrong with Postgres. With the json/jsonb types and queries I guess it can do everything Mongo can do and do it better (though I'd like if someone could point out where this isn't the case).
|
# ? Sep 6, 2017 20:53 |
|
Thermopyle posted:There's not much to learning node if you already know JS and used to installing npm packages. Not only can it do everything Mongo can, but you ALSO have a reliable relational database if, god forbid, you have some relational data.
|
# ? Sep 6, 2017 21:54 |
|
Thermopyle posted:There's not much to learning node if you already know JS and used to installing npm packages. gently caress yes thank you for recommending postgres I am so sick of people bending over backwards for mongo in situations where it gains them literally no benefit. Postgres is also really really good in so many ways.
|
# ? Sep 6, 2017 22:12 |
|
Skandranon posted:Not only can it do everything Mongo can, but you ALSO have a reliable relational database if, god forbid, you have some relational data. The joke here is your data almost always is relational, or becomes relational shortly after you dismiss it as not relational. I've heard reports that http://knexjs.org is pretty good for working with SQL databases, maybe start there. Honestly if you ever get stuck working with Mongo you'll be better off with a grounding in what a good database looks like in Node, as Mongo code often ends up with most of the data's schema and implied relations expressed in their code, not in Mongo, and not necessarily in a consistent way.
|
# ? Sep 6, 2017 23:05 |
|
We've used Knex where I work for a while now and it's worked out really well
|
# ? Sep 7, 2017 00:22 |
|
Bookshelf can suck my god drat balls, though
|
# ? Sep 7, 2017 00:22 |
|
I've got another dumb JS question boys! Say I am passing a callback to a function, that is expecting two paramters, but I only care about the second, is there some sugar syntax I can do for the the first parameter that effectively means "I don't care what this becomes, I just need to put this here so I can access teh second parameter. I.E. code:
|
# ? Sep 8, 2017 17:45 |
|
Knifegrab posted:I've got another dumb JS question boys! No, there is nothing you can do here if your doASyncThing wants 2. I don't see how it could be more succinct than it already is. You could wrap it with doASyncThingErrorOnly, but that basically is what your above line is anyways. Why does that (success, err) bother you so much?
|
# ? Sep 8, 2017 17:48 |
|
Knifegrab posted:
JavaScript code:
(Don't actually do this, it's ultra terrible)
|
# ? Sep 8, 2017 18:08 |
|
Borrowing syntax from other languages, you can use underscoreJavaScript code:
JavaScript code:
|
# ? Sep 8, 2017 18:13 |
|
Sedro posted:Borrowing syntax from other languages, you can use underscore Don't do this either, this isn't skipping, it's just naming your parameters poorly. (success,err) is the correct thing to do, as if someone comes along later, it's obvious what is going on. Figuring out WTF _ means is a waste of time.
|
# ? Sep 8, 2017 18:27 |
|
Skandranon posted:Don't do this either, this isn't skipping, it's just naming your parameters poorly. (success,err) is the correct thing to do, as if someone comes along later, it's obvious what is going on. Figuring out WTF _ means is a waste of time. Ehh, "_" has a specific meaning in most languages either by convention or by syntax..."the language requires me to put a variable here but we do not have a use for it." That information is useful to have.
|
# ? Sep 8, 2017 18:43 |
|
I usually use whocares, dontcare or whatever but that last one isn't super clear, I guess
|
# ? Sep 8, 2017 18:45 |
|
Knifegrab posted:gently caress yes thank you for recommending postgres I am so sick of people bending over backwards for mongo in situations where it gains them literally no benefit. Postgres is also really really good in so many ways. I've rediscovered my love for document storage after learning to use views incredibly liberally. It just returns whatever crazy object I want spread out all over my database. But for replication and less of a need for replication reasons, a SQL database is often a better option. Wish there was a super simple basic SQL database without all the frills of MySQL and Postgres. Like sqlite but not sqlite. Also I would like something better than using blob for file attachments. Nolgthorn fucked around with this message at 19:31 on Sep 8, 2017 |
# ? Sep 8, 2017 19:29 |
|
Thermopyle posted:Ehh, "_" has a specific meaning in most languages either by convention or by syntax..."the language requires me to put a variable here but we do not have a use for it." Munkeymon posted:I usually use whocares, dontcare or whatever but that last one isn't super clear, I guess JSLint recommends that you use the identifier ignore. This communicates the idea way better. (I use JSHint these days, which doesn't have that convention.)
|
# ? Sep 8, 2017 20:23 |
|
instead of naming it with hieroglyphics or 'ignoreMeButt', what the hell is wrong with naming it what it is, and just not using it?
|
# ? Sep 8, 2017 20:26 |
|
There Will Be Penalty posted:JSLint recommends that you use the identifier ignore. Yeah, I agree that a specific name like ignore, unused, etc is more explicit if you're not familiar with the underscore convention/syntax from all the languages that use it. What you should do is whatever is common practice in surrounding code, in your team, and in the community at large. Unfortunately, despite being over 20 years old the JS community still sucks at having widespread conventions for a lot of stuff.
|
# ? Sep 8, 2017 20:31 |
|
ROFLburger posted:instead of naming it with hieroglyphics or 'ignoreMeButt', what the hell is wrong with naming it what it is, and just not using it? Naming it success is accurate and (possibly) useful information, but misses the useful information that it is intentionally not used further on. So really, naming it what it is would be something like successButIntentionallyUnused.
|
# ? Sep 8, 2017 20:33 |
|
I like to prefix unused arguments with _ if I want what it is to be described. Shorter than a long butIgnoreMe suffix, but more descriptive than _ alone.
|
# ? Sep 9, 2017 01:19 |
|
The real problem is the lack of a canonical style guide like a lot of other languages have. Or maybe thats not a problem because it gives all of us something to bikeshed over.
|
# ? Sep 9, 2017 16:56 |
|
prefixing with an underscore seems like it would just introduce even more confusion than it's worth because that naming convention normally means something else entirely. I can't imagine being all that confounded by an unused variable but I can certainly see myself getting distracted trying to figure out why someone would name an argument "_" or "_successHandler". I'm having trouble imagining a scenario where communicating an unused variable would be all that valuable, especially when this is largely a solved problem if you're using modern editors.
|
# ? Sep 9, 2017 17:01 |
|
ROFLburger posted:I'm having trouble imagining a scenario where communicating an unused variable would be all that valuable, especially when this is largely a solved problem if you're using modern editors. Imagine you're delving into code you don't understand.
|
# ? Sep 9, 2017 18:02 |
|
I'm skeptical you're gaining much value there and if you're delving into code that you "don't understand", this distinction is probably the least of your concerns. But as long as you're not further obfuscating the name with an underscore or whatever I suppose it could only help.
|
# ? Sep 10, 2017 00:15 |
|
ROFLburger posted:I'm skeptical you're gaining much value there and if you're delving into code that you "don't understand", this distinction is probably the least of your concerns. But as long as you're not further obfuscating the name with an underscore or whatever I suppose it could only help. Well good news! I don't think anyone is claiming you're gaining a lot of value. This whole discussion is bikeshedding.
|
# ? Sep 10, 2017 00:20 |
|
In Javascript, the frontier is everywhere. We are bounded only by the browser, and the transpilers, and the ECMAScript committee. The open road still softly calls. It has been said that coding is a humbling and character-building experience. To me, it underscores our responsibility to deal more kindly with one another.
Dominoes fucked around with this message at 16:30 on Sep 10, 2017 |
# ? Sep 10, 2017 01:33 |
|
I've been hearing rumblings that REST is dead. That the concept in practice doesn't work very well, that no consistency exists between APIs and that it's basically a crap shoot where the only value derived from it are descriptive urls. But those urls could be replaced easily by descriptive names, in fact names could be those urls or something even more suitable. Also a point of aggression against REST is that no protocol supports it at all except HTTP and then even methods DELETE and so on are inconsistently implemented. If you have a REST api and want a Websockets version it is flat out impossible. People are saying a single API endpoint which accepts json GET or POST is the future.
|
# ? Sep 10, 2017 16:30 |
|
The concept of a universal framework for transmitting data from a server to interaction-vehicle (Browser, standalone app, phone app etc) is great, regardless of the specific format.
|
# ? Sep 10, 2017 16:33 |
|
But I get it. These transmission frameworks are too complicated, in a perfect world I'd be able to simply run a function on a different server. The closest we can come to something so simple is a single parameter in the shape of an object. Or, even, an array of parameters. A single endpoint where I can just send something like code:
code:
|
# ? Sep 10, 2017 16:48 |
|
I don't know much about REST, but it seems like server takes JSON-like data structure (Python dict, JS object etc), => JSON in transmission => JSON-like datastructure client side. Isn't that what you're asking for?
|
# ? Sep 10, 2017 17:13 |
|
|
# ? May 16, 2024 17:50 |
|
Nolgthorn posted:I've been hearing rumblings that REST is dead. That the concept in practice doesn't work very well, that no consistency exists between APIs and that it's basically a crap shoot where the only value derived from it are descriptive urls. But those urls could be replaced easily by descriptive names, in fact names could be those urls or something even more suitable. I think this is somewhat overblown... You definately can have a REST API run over Websockets, I've implemented many, and they work fine. A GET/POST only API is how many APIs are already implemented.
|
# ? Sep 10, 2017 17:32 |