« first day (2909 days earlier)      last day (2262 days later) » 

11:04
Yea, it was a nightmare
The API I was implementing was "JWT Based"
More or less...
https://stackoverflow.com/questions/52621251/pass-variable-javasvcript/52621479

Though this question has been answered I would like to discuss if there is any better approach to achieve this?
Why are you using both $ and jQuery, @techie_28?
sorry that was not intentional,I used jQuery whereas OP had used $
I was concerned about the logic in the answer if that could be done in a more efficient manner or just is right in itself?
I prefer not to rely on this in jQuery event handlers.
.on('change', evt => { const $element = $(evt.target); })
11:21
@MadaraUchiha oi you there?
So I have something to discuss and would like your opinion on it
Sure, you need a private room for it?
nah im typing
11:23
namely, I was wondering what would it be like to push component state to stores, MVVM style, while keeping View - Controller / ViewModel separation, so I went ahead and did that
basically the results are imo:
@techie_28 I wouldn't even use IDs for that, probably
If you put an <input> inside of a <label> you get free association, no id= or for= needed
better extensibility (whenever you need to make something available elsewhere, you just inject)
better testability (if you feel like testing UI)
more typing to do
more SOLID approach
controller / view separation still maintained (store knows nothing about view)
all updates are handled by mobx, so stuff will still be responsive without the need to add some magic handlers
well, not all, but property ones
no idea if I could face some bigger problems in some future, non-trivial scenarios like these, but what do you think overall about this approach, @MadaraUchiha ?
@KamilSolecki What kind of logic the model contains?
11:33
none in this case, its a DTO here pretty much
Why split into two objects then? What are you abstracting between the two?
@BenjaminGruenbaum - so when is .then(r => r) not a no-op?
@JaromandaX When you care about ticks very much.
nothing in this case, but assuming bigger scenarios, MVVM style models could hold things like actions etc. and our VM/Controller could also do some behavior on, for example, setter
@MadaraUchiha that's... actually true but not what I had in mind :)
11:46
@KamilSolecki So what would the store do in that case?
huh? @MadaraUchiha
model is our data store, VM is our model - view connector
@JaromandaX Every .then() is, at least, another microtick.
@JaromandaX he meant it takes another microtick so it changes when the promise is resolved compared to other microtasks queued. That's not what I was talking about though.
oh ticks ... sorry, I was thinking back tick :p `
11:47
Let me ask you that - what undergoes promise resolution when passed to Promise.resolve and how does it check?
@MadaraUchiha in which case? View binds to the VM, vm passes data to and from the model and it may or may not modify it
@KamilSolecki VM = LoginStore in this case, yeah?
You've lost me @BenjaminGruenbaum - but to be fair, I am Australian and been cooking on a BBQ tonight - several beers later :p
@MadaraUchiha yes
LoginModel will be the model
I kind of don't like the extra boilerplate you need to add for each parameter you want to forward
But I don't see much choise in this case in this infrastructure (maybe a Proxy? dunno)
I'm a bit distracted at the moment so can't think too well, I'm afraid 😆 Try again in a few hours?
11:51
sure, whenever you have time :)
0
Q: JavaScript: How to run a function several time with different arguments?

Nuri EnginI'm using ExtJS framework and a run one method multiple times with different parameters. I'm looking a way to make it more consist, easy and maintainable and I guess just vanilla Javascript solutions could handle this? I've tried to collect each param into array and using Array.map() as well f...

Vote to close (and sent to stackoverflow preferably) thx
@JaromandaX lol, I'm asking - let's take a step back - how does a then decide to "wait" for an internal promise?
How does it judge that something is a promise?
@BenjaminGruenbaum if it is thenable
@BenjaminGruenbaum But you'll never get a thenable as r in that example
For better or worse, you have automagic unwrapping
Oh, don't tell me you're trying to be a smartass and are thinking of get then() { return randomFunction(); } or something
That would be low :P
damn i wanted to answer more on SO today but I accidentally repcapped
11:59
@JaromandaX right, what trick might one do in order for something to not look like a thenable?
@MadaraUchiha well, close
"thenable" is not a word
The question is also explicitly how to be a smartass
@BartekBanachewicz Hmm, did anyone suggest it was?
It's a technical term, not all technical terms are words - although I'm really not sure what the cutoff is
@BenjaminGruenbaum are we going to Fool Penn and Teller - not sure, I've never tried any JS tricks :p
12:00
That is, language is statistical, I wonder if we have a formal definition of something being like 60% a word
Does TS specify a standard Promise interface?
@BenjaminGruenbaum 60% or word looks a bit like woi :p
And further, does it specify a Functor?
@BartekBanachewicz Yes.
@BartekBanachewicz No.
Sam
Sam
@Cerbrus How was it a nightmare? :P
12:03
@BenjaminGruenbaum You can wrap it in a proxy so that sometimes it has then and sometimes not, with the has and get traps
I found it remarkable that you can extend from Promise in TS
But that's a whole lot of effort just to be a smartass :D
@KarelG Why not? You can extend from Promise in JS too, by design.
@Sam their implementation was shit
Their documentation was shit
And we were apparently alpha testers
Sam
Sam
AH. I'm using a decent lib.. I'm just struggling with design concepts for refresh tokens!
@BenjaminGruenbaum I guess you could slap that under neologism
-> It's understood
-> not a word by definition
-> works
12:05
@MadaraUchiha that's more in line of what I was going for (a getter also works). As a fun fact (which you probably know) the A+ spec requires you to only access .then once (and not twice) in case it's a getter.
@KamilSolecki til (about the word neologism)
Sam
Sam
@Cerbrus Reckon I should both link distributed refresh tokens to users and perform a check when said user tries to obtain a new access token using their refresh token? I have an endpoint which allows this access token generation pending a refresh token but it seems a little unsecure should the refresh token become exposed
I think "it's understood" is the best definition I've heard for "word"
Oh, I don't know about the server-side aspect
Sam
Sam
Ah. Fair enough
@BenjaminGruenbaum Oh, so one has to go to the trouble of deliberate assholery (also not a word) to make .then(r=>r) not a no-op
12:08
@JaromandaX Oh yeah, for sure
@JaromandaX I certainly did not mean to imply differently when starting with "let me give you a trick question (if you feel like it)" :D?
The great trouble, even.
Vs, for example "I have a question about something one would reasonably do"
!!wednesday
12:09
{ p: Promise.resolve(), get then() { return (Math.random() > 0.5) ? p.then.bind(p) : function() {} } or something confusing like that would work
@BenjaminGruenbaum I was so intrigued, I forgot the conversation started that way! For a while I thought I was wrong to say "remove that rubbish code" :p
not that I was so rude, of course
The rust room being dead, the JS room should be the ideal one to ask rust questions, right ?
Lol, doing .then(x => x) is mostly useless, like catch(x => { throw x; })
@DenysSéguret yes
unless you're playing catch, in which case it's perfectly good etichette to throw the ball back
12:19
coincidentally, it just resurrected...
@BenjaminGruenbaum it never ceases to amaze me how much bizarre coding people do in order to turn asynchrony synchronous
@DenysSéguret So, that room's gotten a little "rusty"?
Get out.
@Cerbrus you must be a Dad
@JaromandaX heck no xD
12:23
well, that's a good Dad joke ... i.e. a bad joke :D
I'll just take that as a compliment.
👁 🏃 🐂 ⛐
I ran bear skid
eye run ox slide
@JaromandaX oh definitely, but that just shows us we have a problem .
12:27
rust
Pretty sure that's a bear
:ox: triggers it
That is, the fact a lot of people do something means we messed up when building the API - not that people are stupid. The promise constructor was probably not a great idea in retrospect (saying that as someone who really supported it initially) and the language should have had async/await sooner.
Can I inject props in reactjs like this -> <MarketingCard {...item} userId={logged_in_user} /> is it correct ?
Also, recursive assimilation isn't realy great IMO
12:30
@funjoker have you tried it?
and?
@rlemon It is not giving any error I just want to ask is it correct method ? or bad practice ?
idk how others feel about it, but it's used often enough you're probably okay
it's "understood"
ok thanks
12:34
if you wanna read more google "jsx spread attributes"
Yeah that's fine, but JavaScript variables are typically not snake_cased (sorry @snek)
they are camelCased
Ok
it will not give error right ? If I don;t use camelCase
That's just a convention, but it's a good one
Ok I will do it thanks
Generally a good idea to use a tool like eslint to track style in a project
12:41
Ok I will add eslint extension in visual code studio
might want to simply use prettier for formatting
Do you use it @ThiefMaster ? I've seen eslint --fix a lot more often
it has a pretty decent style (assuming you tell it to use single quotes and trailing commas)
not yet, because there's a bug increasing jsx indentation based on the number of boolean conditions in case of {foo && bar && <...>}
Yeah, I'm just familiar with a lot of people in a similar situation (where they wanted to use prettier but ended up not doing so)
but once that's fixed i'm considering to add it. usually i'm not a fan of opinionated formatters with close-to-no config options, but in this case it has decent opinions
black for python on the other hand.. only over my cold dead body
(they use double quotes, and the only way to avoid it is disabling quote handling altogether)
12:44
Why I am getting undefined text variable in below code:
constructor(props) {
        super(props);
        this.state = { text: '' };
    }


<View style={styles.iconContainer}>
                            <TextInput style={styles.commentInput} maxLength={40} underlineColorAndroid='#FFFFFF'
                            placeholder={'Leave a comment'} onChangeText={(text) => this.setState({text})} value={this.state.text}/>
                            <TouchableOpacity onPress={this.addComment(text, this.props.userId)}>
                                <Icon style={styles.sendIcon}
I am getting cannot find text variable ?
In general - people will not be able to help you in code they cannot run.
Oh ok
Look at the difference between onChangeText and onPress
but in this case, it's pretty clear ^^ do that
Yeah, in this case it's not the sort of issue you should bring to chat because it's something you can relatively easy figure out yourself by using the inspector.
If you haven't done so already - I warmly recommend learning to use the Chrome developer tools - there is a nice free course you can take if you want to.
12:47
@BenjaminGruenbaum onChangeText and onPress is used in react native ? what is wrong in it ?
can you share that link?
I could share it to others myself when asking another to use dev tools to troubleshoot something
@funjoker look at your code carefully for both of those handlers.
@BenjaminGruenbaum async/await is still used inappropriately way too often, I think a lot of coders don't understand its link to promises. Up until one question I answered today, I always thought async/await was a crutch for people that can't get their heads around promises, but I've finally seen code that is far easier to write using async/await than not
@JaromandaX I use async/await almost exclusively and I'd like to think I have a fair grasp of promise chaining.
@BenjaminGruenbaum Oh yes got it. It should be onPress={this.addComment(this.state.text, this.props.userId)}
Can some please tell me how can I debug react native apps in browser ? is there any way ?
12:51
React Native Debugger
@BenjaminGruenbaum unfortunately in my job I don't get to use async/await ... because we need to support IE11, and everyone I work with think transpiler is character from Transformers :p
async/await is great, makes code easier to read/write
7 mins ago, by Benjamin Gruenbaum
If you haven't done so already - I warmly recommend learning to use the Chrome developer tools - there is a nice free course you can take if you want to.
async await is confusing :( I am not able to understand when to use .then() .catch() and when to use async await
12:53
@JaromandaX this is a job thing though - if you used a transpiler (I use TypeScript for example) that wouldn't be an issue.
@funjoker How long have you been trying to grok it for? Learning a concept like this usually takes a few weeks of actually trying to understand what's going on and why.
Keep messing with them, one day it will just 'click'. Also, understand promises, as that is what they are underneath it all
@JaromandaX "still way way better than callbacks" though :D
@TravisWhite "understand promises" is pretty hard to measure to be fair.
I have understood promises i.e .then() and .catch() but aysnc await is just new syntax for it am I right ?
@JaromandaX Please don't post unformatted code - hit Ctrl+K before sending, use up-arrow to edit messages, and see the faq.
@CapricaSix sorry, haven't been in a chat in a while :p
12:56
@JaromandaX Why not? That sounds fine
True, but I tried to learn promises at the same time as async/await and it was way more confusing jumping between the two
@JaromandaX question #2 - what is the difference between that and not using async/await? (There is one, and it's not tricky and one I care about though a lot of people don't)
@JaromandaX So what is the right way ?
you need to pick up edits
:/
@funjoker start with actually understanding promises: exploringjs.com/es6/ch_promises.html
12:57
@BenjaminGruenbaum I'm sure it has to do with error handling
@JaromandaX it does, sort of - debugging more generally.
I think he just means it is unnecessary to define the encapsulating function as async/await if it is returning a promise and not calling any other asynchronous code
@TravisWhite that's what I was getting at (still can't get the code thing right here even after reading the FAQ - too much drinking I suspect)
@BenjaminGruenbaum So I just want to ask .then() and .catch() must always be used on asynchronous functions am Iright
@JaromandaX dark theme -> code mode -> don't mix text/code
13:02
@funjoker that question indicates you should really consider reading that chapter I've sent if you want to avoid a lot of frustration.
@JaromandaX or you know, it's just confusing that it works in a certain way in Stack Overflow chat and that way is different from literally any other system using markdown (Stack Overflow, GitHub, Ghost, etc)
This is a basic question but
jQuery.post( url [, data ] [, success ] [, dataType ] )
how to read that?
that's why I like code mode, sure the tabbing and formatting help, but when you're in code mode, you know it's going to be posted as code
@rlemon I don't use Chrum :p
Breathing, url required, others are optional
I can kinda understand what it means, but there must be some guideline to understand
13:04
jQuery.post is the method
url is a required argument
Anything else after that is optional.
@JaromandaX someone recently did a FF port
who made [,] as optional?
@rlemon was just about to search :p
It's that way already in the commandline so I guess that originated quite early.
I don't think it is some universal standard, just guessed based on context
13:05
alright
or that, lol
idk why it's a different port, and not just a build from mine, but meh.
@rlemon already found it but thanks
> RENAME [Drive:][Path]Filename1 Filename2
REN [Drive:][Path]Filename1 Filename2
I just had REM flashbacks
thanks
13:07
<3
For example is the help for the rename command.
@BenjaminGruenbaum Ok I will read it
great, now I'm going to be humming losing my religion all morning
:(
Oh, this dark mode is much easier to read 😃 thanks @rlemon
buncha hidden little js gems too
roses are #f00
@TravisWhite you are aware that an async function returns a promise; but many aren't
13:11
@KarelG I always say that async/await is syntax sugar for promises - but that's a little unfair
@JaromandaX Never underestimate the power of the dark mode!
collapsing oneboxes is probably the best feature
and I stole it from Slack
Has someone made a dark mode for SO
@karelG not sure? guess not, example?
@JaromandaX yes
not me, but someone
it's on here iirc
13:13
@TravisWhite just an exaggerated example but I have seen it once somewhere on SO:
async function calcThis(arg1) {
   // await xhr server
   ...
   return val1;
}

const total = calcThis(obj1) + calcThis(obj2); // QQ probl
I've seen return new Promise(.... in an asynchronous function
Ugh. Async* damn phone
@rlemon great, it's a userscript too, so easily changeable - oh, it just injects CSS - simples
@rlemon +1
I should work on robogist again. I do think it has potential. Maybe
@KarelG Are you saying many people aren't aware async functions return a promise? Or that many async functions don't return a promise?
13:19
@rlemon async function delay(ms) { return await new Promise(resolve => setTimeout(resolve, ms)); } actually sounds OK to me, tbh
@TravisWhite aren't on "being aware async returns a promise". So they do not know that async function returns a promise
Ahh, see, yeah I was second guessing everything I knew about async functions with your example trying to understand how it wasn't returning a promise
const delay = ms => new Promise(resolve => setTimeout(resolve, ms));
I misread your original question, yes, it should be made clear async/await is just sugar for using promises, they are promises underneath it all
@JaromandaX Yes, but there are benefits to being async all the way, namely, async stack traces.
13:23
Looking at the code of how async/await is implemented may be enlightening for many, It helped me get there
@MadaraUchiha OK, back to stack traces - geez, who needs them when you write bug free code :p
const delay = (ms, now=Date.now()) => while( Date.now() - now > ms );
fite me
@rlemon seems legit
@TravisWhite really? It's not too readable.
@TravisWhite Do you know how generators work?
13:25
chromium.googlesource.com/v8/v8.git/+/… I read an article that broke it down, explaining async/await, using the code and explaining it, let me see if I can find it
The key point is it is simply a wrapper for promises
FYI - the question today that changed my view of async/await - stackoverflow.com/questions/52620328/…
@TravisWhite That's not how it's implemented? That's an old commit - but I like the sentiment
                });
              });
            });
          });
        });
      });
    });
  });
});
I have a slide somewhere I think
13:26
@TravisWhite Imagine a generator that yields promises and gets its onNext called with the resolved value of the promise when it returns
> that is just so flat and sexy, right
Of course, if you want to totally NOT understand async/await - check out how babeljs transpiles them!!
I have to disagree. I prefer the .then's
@JaromandaX You mean, as a state machine? That's how generators are implemented too.
@KarelG one of my more obscure phrases I must admit
13:28
All that is intuition - it's just not how it's implemented (there was a step where it was the initial implementation IIRC)
@MadaraUchiha yes, as a state machine - but the first time I looked at it, I cried a little
@JaromandaX Eh, yeah it's scary when you don't know what it means, but once you do, it's fairly understandable.
@KarelG to be honest, so do I - but there's a lot of cruftiness about the .then's
But it's still a state machine like a generator and it's still fundamentally similar
Async/await is part of ignition and then gets further optimised by turbofan - but the bytecode is converted to a state machine at the interpreter - at least in V8
I'm rather clueless about what other browsers and engines do
You guys win, I must have been reading psuedo code for the implementation explanation. Key point is the same, they use promises underneath it all/return a promise.
13:31
@TravisWhite "win"?
hey @rlemon can't remember where to find it. New laptop, but you made a plugin for SO chat right?
I'm just happy people are willing to talk to me about all this :D
Thanks my guy!
The actual implementation is actually totally irrelevant.
13:32
What the heck ... today I must've seen about 10 questions that start "I'm quite new to [xxx in] JavaScript." - is this a new trend?
conceptually it's about pausing the function to wait for Promises
I'm not trying to "win", sorry if it came off as needlessly argumentative - you sent a v8 code reference (which I liked - so I sent a more recent one on the topic since your reference was out of date). Did I come off as needlessly argumentative? @TravisWhite
@JaromandaX school started a little while ago
AHHH my eyes, much better.
13:33
mid sept -> christmas the questions decline
oh, where? (it's almost midnight here)
@MadaraUchiha I think it's interesting regardless - but I get what you mean.
no I mean in general :P
@BenjaminGruenbaum I like to give the analogy to .map()
@rlemon we do things differently in Australia
13:34
From a pure perspective, .map() is a specific case of .reduce(), which is, again, from a pure perspective, implemented with recursion.
No one really cares that it most likely is not implemented with recursion in JS under the hood, it's just irrelevant.
@JaromandaX up north of the equator we do school from sept -> june-ish
You use .map() to begin with to avoid this discussion and be able to talk in terms of "map this array to that array"
@MadaraUchiha map can be seen as a renaming of a specific case of a reduce - but that's certainly not the only way to obtain map or the "most correct" one IMO.
@rlemon I know ... we go End of january to Mid December - only a ~6 week summer break, unlike you softies up north
@MadaraUchiha I care about how .map is implemented just because it's an interesting thing to know
13:37
@BenjaminGruenbaum Agreed
@JaromandaX yea but you guys don't have to trudge through snow for 6mo
I'd say it's fair.
@rlemon touché
but I just remembered the cane toad documentary I watched, so idk. snow or cane toads. hard choice.
@BenjaminGruenbaum wasn't map more performant than .forEach in V8 some years back? I could never understand that
@JaromandaX you do not have full days of school right ?
13:40
@KarelG huh? 9 to 3 on average
> The typical school day is from 9 a.m. to 3:30 p.m
Thanks for reminding me that there is a dark theme :)
I never went to post secondary. HS was like 8am -> 2:30
so the time lines seem to be similar
@JaromandaX it's just implementation detail most likely - but probably not.
@rlemon cane toads are about the only thing in Aus that won't try to kill you
13:40
during my high school, it was from 08:25 until 16:35
It's possible that some things are faster just because there is more incentive to optimize them.
@JaromandaX cept that one guy who was stabbing them and hit a power line :D
@rlemon licking them is apparently ... no, don't do that - even the plants want to kill you here
that reminds me of that scene from The Simpsons
yea, we're lucky that most of the dangerous small animals die in the winter
but moose with make you have a real bad day if you piss one off
13:43
Bullfrog? I'd have called it a Chazwazzaa
now I'm curious if moose are more dangerous than trees in Canada.
I'd think Trees kill more people a year than moose
yea, 2 people a year from moose
windowmakers take out a lot more :/
Trees > Moose
@rlemon is that 2 people per moose? :D
I'm not sure if they count car crashes involving moose
because if you hit a moose, you're probably dead.
we are having problems with canadian goose here
not moose but goose
(we shoot them off)
yea, we have the same problem
Canadian Geese are angry and wanna fight you always. sounds like a perfect animal for Australia! :P
13:53
No, Australian geese don't wanna fight you. They wanna kill you.
I wonder who would win, a roo or the equiv weight of canadian geese?
Australian geese are confined to one building in Canberra - we call them "politicians"
hmm how to make firefox ignore cors? So I can dev the front end separate from the backend?
I'm trying to extend a class without using the ES6 convenience wrappers (stupid IE11) but I've not been able to get it to work using Object.create(Parent);. Is there something I'm missing?
@rlemon a roo, hands down - they be tuff muthers
13:55
ohh I'm aware. they're giant roided out rats.
but geese are surprisingly tough.
and there are a lot of them
@JaromandaX there is a TV series with a roo... Skippy
@Machavity What are "ES6 convenience wrappers"?
@JaromandaX class Child extends Parent
@KarelG yes, I live about 10 minutes from where that was filmed ... almost 50 years ago :p
@Machavity I always forget how to do that for IE11 - so I cheat and use babel repl :p
Which is how I'd much prefer to do this. I write PHP mostly so it mirrors that. But we have enough customers still on IE11 I can't just stick it to them
13:58
@Machavity Parent.prototype?
@rlemon I spent a year in Vancouver - never saw a goose, so I can't say I can compare
Child.prototype = Object.create(Parent.prototype)
@BenjaminGruenbaum No, sorry. Win was probably a bad way to put it. Was in a hurry to write that. But you guys proved your point was what I mean. The generate code certainly isn't easy to understand and I was trying to search for the code I originally seen that explained the async/await implementation, but couldn't find it.
Yeah, I don't know - when people say "win" it makes me feel uneasy - it's terminology people tend to use when they feel in an argument and not a discussion - that's probably a "me" issue.

« first day (2909 days earlier)      last day (2262 days later) »