« first day (4000 days earlier)      last day (931 days later) » 

3:30 AM
 
4:06 AM
hiya, I want to make some visualization like this website music-map.com I try to find a similar example in several js libraries but cant found something like that (words effect around central issue, etc) any hints?
 
 
2 hours later…
6:04 AM
    function loadScript(src, callback) {
            let script = document.createElement('script');
            script.src = src;

            script.onload = () => callback(script);

            document.head.append(script);
        }

        loadScript('https://cdnjs.cloudflare.com/ajax/libs/lodash.js/3.2.0/lodash.js', script => {
            alert(`Cool, the script ${script.src} is loaded`);
            alert( _ ); // function declared in the loaded script
        });
What is the meaning of underscore here? How it shows the function definition?
 
6:30 AM
@DamodaraSahu underscore is the global variable defined by Lodash.
 
 
2 hours later…
8:12 AM
is it really a good idea to change things in node_modules folder? stackoverflow.com/a/69187990/4826457
 
8:33 AM
How much of an anti-pattern are callback functions defined in functions just so that variables of the outer scope stay available? (e.g. chains of let var = document.createElement() that are then accessed in callback functions that are later attached in the same function)
Simple example
let button = document.createElement("button");
let div = document.createElement("div");
function clickHandler(event) {
    let span = document.createElement("span");
    span.innerHTML = "Clicked. "
    div.appendChild(span);
}
button.addEventHandler("click", clickHandler);
We have quite a lot of this here in a project and I wonder if me replacing that stuff so the click handler fetches the references back from the document and place the clickHandler function outside of its generator code would be better for maintainablility
function generateDOM() {
    let button = document.createElement("button");
    let div = document.createElement("div");
    div.classList.add("something");
    button.addEventListener("click", clickHandler);
    document.body.appendChild(button);
    document.body.appendChild(div);
}

function clickHandler(event) {
    let div = document.querySelector(".something");
    let span = document.createElement("span");
    span.innerHTML = "Clicked. "
    div.appendChild(span);
}
 
@salbeira Please don't post unformatted code - use the up arrow to edit your post, then hit Ctrl + K to format the code in that post. See the faq. You have 25 seconds to edit and format your message properly before it will be removed. Please separate code blocks from your actual question. Put your question in 1 message and then your code in a 2nd and format it.
For posting large code blocks, use a paste site like like gist.github.com, hastebin.com, pastie.org or a demo site like jsbin.com
 
8:59 AM
@SurajRao No. It's the same thing as with any third-party dependency you have. You can change it, sure but you can only do that on your environment. Not on everybody's machine. And when the dependencies are updated, you'd lose that change.
Dependencies should only be consumed, never altered. If you some change is needed then your last course of action should be to edit them in node_modules.
@salbeira The semantics are different between the two versions. Declaring let div = document.createElement("div"); outside the function means there is a single div that is going to be re-used every time the function runs. If you put it inside, then one new div is created every time the function runs.
 
@VLAZ I figured something like that. Was surprised with the accepted answer and voting. Probably a "hail mary"?
 
@VLAZ I forgot to surround the first example code with the generateDOM function symbol but the semantics are equal
function generateDOM() {
    let button = document.createElement("button");
    let div = document.createElement("div");
    function clickHandler(event) {
        let span = document.createElement("span");
        span.innerHTML = "Clicked. "
        div.appendChild(span);
    }
    button.addEventHandler("click", clickHandler);
    document.body.appendChild(div);
    document.body.appendChild(button);
}
That would be how it looks rn
And I wonder how much of an anti-pattern this is
 
Well, this would be better. Avoids clashes with some other function needing a let div declared before it.
 
Cause it is ordered this way simply so div is in scope for the callback
Wait so the nested functions are good?
 
@salbeira Do you mean the before your refactor or after the refactor is an anti-pattern? The before is not terrible. Wouldn't call it an anti-pattern because you can get away with it in many situation. The latter is much better and definitely not an anti-pattern.
 
9:08 AM
With the latter you mean the "split" one with two separate functions where the clickHandler fetches the reference or the one I "corrected" after the fact so it is clear how they are related?
 
By "the latter" I meant the last piece of code you showed.
The split thing functions slightly differently to the other two.
 
uh ... how do you think they work differently?
And ... I would want to remove the nesting and split them apart
Cause this generateDOM() function is by now about 500 lines long and contains a lot of nested functions that I personally can not keep track of why what when a variable comes from the outer scope
This is a case of we have 20+ different DOM elements created in the first 20 lines of code of the generateDOM function and another 300 lines of code of click handler callback functions that use the variables declared in these 20 first lines of code so they are in scope
with another 100 lines of code consisting only of "element.classList.add("foo")" code and "element.setAttribute()" code and element.appendChild(bar)" code
 
@salbeira As I said, it would create a new div every time the click handler runs. If you do want to split them, then you can have the clickHandler accept the div as an argument. Then you can create it outside and pass it in, so it's re-used.
 
How would document.querySelector() create a new div?
And how would I pass another argument to a click handler? it gets the event as per the signature of a eventHandler function
Have you misread the first line of the split solution as another document.createElement()?
 
 
2 hours later…
11:13 AM
@salbeira button.addEventListener("click", (e) = clickHandler(e, div)); is the easiest option. You can also curry the click handler as clickHandler = div => event => { /* do stuff with both div and event } */ and then attach it as .addEventListener("click", clickHandler(div));
@salbeira Sorry, you're right. I misread it as another .createElement(). But I don't like that. There is now an implicit coupling between the two function that can be hard to detect - one adds an element with a class of something, the other searches for a class of something. If either of the two functions is changed and the class they add/search for is changed, now the functionality is broken and it's not easy to find out why or how.
 
That would involve using the scope catching again which is the whole thing I am having headaches with
But yeah I see where this is an advantage
 
Making the dependency explicit by making it a parameter is easier to maintain. Then the function doesn't depend on scope and can be moved anywhere in the code, doesn't need to be housed within another. It can also be very easily tested individually without having to invoke the "wrapper".
 
11:48 AM
posted on September 28, 2021 by Michaël Zasso

Notable Changes [3a60de0135] - assert: change status of legacy asserts (James M Snell) #38113 [df37c106a7] - (SEMVER-MINOR) buffer: introduce Blob (James M Snell) #36811 [223494c548] - (SEMVER-MINOR) buffer: add base64url encoding option (Filip Skokan) #36952 [14fc4ddabc] - (SEMVER-MINOR) child_process: allow options.cwd receive a URL (Khaidi Chu) #38862 [b68b13acb3] - (SEMVER-MINOR) child_pro

 
12:17 PM
o/
 
 
2 hours later…
2:36 PM
> it seems that if i have a nested function with an async call, every parent function has to be defined as an async function. this just doesn't seem right; am i missing something?
From a question somebody posted. I guess they are slowly realising what async really means.
 
@KevinB Yeah. The question I mentioned was asking if turtles async all the way down was correct. So slightly different focus. Still, it comes from the same expectation that perhaps there is some magic way to convert async data to sync and stop awaiting.
Well, there sort of is a way. You can define your functions to accept the data as a parameter and then work with it. Then it doesn't matter if it's sync or async. You thus need a single a(await getSomeAsyncData()) and that's a single await then when a calls b and b calls c etc, they don't need to await anything.
But users usually want to call a which calls b which calls c which then gets some async data.
 
Finally hit another milestone
 
2:57 PM
🚽
 
πŸ’…πŸŒ­πŸ”₯
 
 
2 hours later…
5:26 PM
@makadev I have encountered an issue
jsfiddle.net/BeerusDev/xsbeac82/15 Cannot get the createByID to work in that different structure of the filter
 
5:44 PM
Is it alright to post my stackoverflow question in here or dpaste?
@BeerusDev by any chance do you play apex
 
generally no, but the room is so dead i doubt it'd be problematic. Just don't make a habit of it. It's often better to instead ask your question here in a way that works for chat
rather than just linking to your question on SO
put another way, chat isn't a place to request more views on your question, it's a place to discuss it
 
I see, I'll try in the future to re-word for chat, it's just this one is lengthy.
0
Q: Cannot Clear Array Data Property in Vue.JS

NRU0I have a very simple training exercise I am completing which involves creating a few selectors using async functions. It basically works like this, once the user has selected a country then they can select a state, then they can select a city. The issue I am facing is when the user selects a new ...

 
6:17 PM
posted on September 28, 2021 by Srinivas Sista

The Dev channel has been updated to 96.0.4655.0 for Linux and 96.0.4655.5 for Mac. Windows update is coming shortly. A partial list of changes is available in the log. Interested in switching release channels? Find out how. If you find a new issue, please let us know by filing a bug. The community help forum is also a great place to reach out for help or learn about common issues. Srinivas S

 
I do not, why whatsup
 
6:47 PM
oddly enough I played with someone on Apex, his username was LordBeerus and his Bio said Developer Guy, and then I see you
would have been a really small world if it was the same beerus
also I solved my question
to those who viewed, it was an issue in which how I was propagating my array elements to my select element, I was creating the options using createElement in JS and then using appendChild to add them to select, when I should have created an option element directly in my HTML and used v-for, key:item associated with my array data property to render them, this enabled me to be able to clear the array
 
7:13 PM
o/
If I create a WebSocket connection in one component, how can I use it in another component? Can something like this be stored in the redux state (I think I cannot be)? I found this answer: Reactjs: how to share a websocket between components but I don't understand this comment underneath it:
Render will create multiple connections on server side. This is not optimal. — JKhan Jun 11 '19 at 14:38
 
not sure how to accomplish it with redux
it was trivial with mobx
 
my understanding is, redux has a single store for the entire app
so for multiple components to share a websocket connection, the connection would need to be made somewhere more global than the components that need to use it
because you don't want to end/start the connection every time you change
with mobx, you can have many stores, so i'd just have a store specific to the socket connection
 
πŸ€” Hm.. it might work then... redux does have a single store but you can store pretty much anything you want to store in it. Like this... It creates a chat like this
 
7:29 PM
to be clear, my issue with redux is i've refused to use it, not that it can't be done, ;)
surely it can be done
 
πŸ‘πŸ‘ Ok I'll give it a shot! Thank you :)
 
8:23 PM
posted on September 28, 2021 by Daniel Gagnon

The Dev channel is being updated to 96.0.4652.0 (Platform version: 14244.0.0) for most Chrome OS devices. If you find new issues, please let us know by visiting our forum or filing a bug. Interested in switching channels Find out how. You can submit feedback using β€˜Report an issue...’ in the Chrome menu (3 vertical dots in the upper right corner of the browser).  Daniel Gagnon, Goo

 
 
1 hour later…
9:50 PM
@KevinB lol, yes
 
i'd rather use php than redux
6
 
 
2 hours later…
11:39 PM
After using XCode for 5 min, I can objectively say it sucks
tbh JetBrains IDEs are quite possibly the best piece of GUI software I've ever used
 

« first day (4000 days earlier)      last day (931 days later) »