Placeholder Image

字幕表 動画を再生する

  • Good morning.

  • Almost forgot.

  • Thio a Knute, my Mike Welcome you here A little knees, Aly extra uneasily sound of my voice is a little quieter if I have a little less mistake Wa veuve enthusiasm The enthusiasm is deep in my heart I'm getting over a cold And actually, now that I couldn't speak, I think it must have thought.

  • But I want to cancel today because I've got some momentum with this every Wednesday thing.

  • And I do know, as a matter of fact, that the next two weeks or a little, I'm gonna try to keep this every Wednesday thing.

  • But I know for sure two weeks from now I won't be here on Wednesday on and I'm not so sure about next weekend.

  • But I have some plans, an extra bonus live streams.

  • So, uh, today might be a bit of a shorter at the so thio.

  • Very minor minor.

  • Just a little bit of a cold.

  • It's note.

  • Here we had a snow day that was exciting thanks to everyone who indulged a little extra noise.

  • Looped video where I walked the streets of Brooklyn on, talked into a camera, was wearing a baseball cap trying to channel my inner youthful youtuber.

  • I don't know how well I did, but it was an attempt.

  • So I've got some, Uh uh.

  • What I view is exciting things to talk about and showed.

  • And I also just one of a kind of reset a little bit because I have been obsessed, as you may have noticed noise, different noise algorithms, classic Perla noise simplex noise, open simplex noise.

  • And I've been doing a lot of videos about that.

  • I've been looking at techniques for looping noise by adding extra dimensions and using polar coordinates.

  • It's been glorious.

  • Gets baby time for me to take a break from that.

  • Although there's little time towards the end of today, I would like to apply the looping noise to the terrain code, which is something that I said at the end of my video that I would do if I don't get to today, I'll certainly release that code.

  • People are telling me the stream is very Laghi.

  • Oh, all right, I've been talking all this time and no one has been able to hear me.

  • So I do see here in my, um uh, in my live control room YouTube life control room that I'm getting bad quality.

  • Okay, let's try restarting.

  • Oof!

  • Okay, now it's fine.

  • I mean, I'm tempted to just restart here.

  • Let's restart.

  • It's fine now.

  • Okay.

  • All right.

  • So I was about art, but apparently, did anybody catch anything that I just said?

  • I suppose hopefully when this gets published, Aggie, the actual words that were coming out of my mouth will be heard on the archived version of this video.

  • Is that okay?

  • So All right, let me just at least let me just repeat myself.

  • I don't know what else to do but repeat myself, which is not a good idea, considering the state that I'm in it.

  • I have a good day.

  • It's called a box of Kleenex.

  • The coating train today is sponsored by the common cold.

  • It makes your head congestion.

  • Your brain is in a fog.

  • You shouldn't be live streaming on YouTube.

  • I'm a little bit sick.

  • I thought I actually have felt.

  • When I woke up this morning, I felt pretty good.

  • And I haven't been doing very much for talking very much.

  • Just started.

  • I realized it was a little shaky, but I am going to proceed with today.

  • This will be a bit of a shorter stream than usual, so that I don't overdo it.

  • But I wanted to make sure that I came here because I've got important things to say and important.

  • Well, I don't have anything important to say.

  • I've got things to say.

  • I've got stuff to code common cold.

  • You're not gonna get me down.

  • Uh, lad comes again.

  • All right?

  • Now, some of you are experiencing lag.

  • I am also the part where the words come out of my mouth.

  • There is a lot of lag in between there.

  • There's, like a little loading animation that's in front of my eyes, as I think, an attempt to speak and I'm gonna go check the life control room.

  • It still says bad.

  • I'm tempted to restart.

  • Why don't I just restart?

  • Should I just restart?

  • I should probably start Oh, getting mixed and getting mixed signals from the chat.

  • But all right.

  • Okay.

  • In theory, I am back.

  • Now I am going to look at We'll see how this goes.

  • The good news is on everything to disk.

  • So nothing is lost until the computer decides toe die.

  • I see that people are saying still lag, so doesn't seem to have corrected itself, which is somewhat unfortunate.

  • Uh, let me just put on the waiting music sometimes takes a minute.

  • The question is, is this on YouTube's and or is it on my, uh, could be could be the Internet connection that I'm using here and why you I am not streaming through WiFi street for the Ethernet cable plugged into the wall of line.

  • So But I do have, like, a lot of things are lagging.

  • I've got just jobs.

  • Maybe this is all for the better.

  • I could come back later today.

  • It's very hard for me.

  • Oh, actually, this will be fun.

  • Let's try something.

  • Let's try a little experiment.

  • Okay.

  • So what you doing here?

  • Okay, most of you probably can't see this, but I'm gonna attempt to run this Internet speed test.

  • What I did is I just used in open broadcast studio.

  • I'm doing, like, window capture to grab the browser window on the computer that I'm streaming from.

  • Um, you can see my i p address now on broadcasting that out.

  • Let's see how this goes.

  • So I don't know if you can see this, but it looks like I'm getting a download rate of about 430 megabits.

  • And here comes the upload.

  • This should be good for streaming.

  • Let's check.

  • My still says bad.

  • Uh, I mean, come on.

  • Look at that.

  • Can you see this?

  • This doesn't look like it's my on my end.

  • Right.

  • Oh, all right.

  • So now it seems to be fine.

  • Okay, Now it's working black.

  • Uh, Okay, well, let's proceed then, shall we?

  • It was kind of hoping, in a weird sort of way, I was hoping it was just gonna get worse.

  • I think maybe I should be taking a break.

  • I know.

  • I know you're here to watch this live stream, and you don't want me to be secretly hoping that the whole thing turns off so I could go downstairs and rest.

  • But if I'm being honest, that's a for a moment.

  • That's how I felt.

  • Okay.

  • Huh?

  • So looks like my speed tests seem to fix things.

  • Oh, it says good now.

  • Okay, So my YouTube live control room says good.

  • Let me remove this window capture.

  • And, uh, I think I'm actually just gonna delete that, and I think I'll get started.

  • I've got going here.

  • There are teams of people, all working 24 7 rotating shifts of engineers, curriculum writers as designers, makeup, hair, costume design Just to make this happen, right?

  • A person named Dan Shiffman standing here talking to you live on the Internet.

  • All right, d at least cover some important announcements.

  • I can't even hear myself speak.

  • That's how congested my head is.

  • It's not good.

  • Uh, all right.

  • Browser and I have some announcements to make.

  • First congratulations to the 2000 I like.

  • I'm talking to the camera.

  • And then I turned over to refer to this thing that I have here.

  • And it just all I see is black, black, black, black, black, black, black, black, black like like that black in the still says Good.

  • Let me check the slack channel buffering.

  • I bet it's encoding problems.

  • Not network, Alka.

  • Right?

  • I bet it's encoding problems, not networks aware.

  • Where would that be happening?

  • Like you mean, like on the O.

  • B s level or like you doing it's back PC already?

  • Um, isn't it?

  • Isn't it possible that this is a problem?

  • YouTube's end?

  • I mean, no I Okay, on the bottom, Right of O B s, I have a green icon.

  • I have CPU, 10.3%.

  • 30 frames per second.

  • Um, and, um, kilobytes per 2nd 5170 people.

  • Tell me it's, um, already view stats.

  • There's more information there.

  • Okay, view.

  • So I'm seeing view.

  • I don't see something just called stats here.

  • Here.

  • I'm gonna share with you all.

  • I mean, you can't really see this because it's lagging, but I'm gonna show B s window.

  • Let's see if I can do that a little behind the scenes here today on the coding terrain.

  • Oh, now it's red.

  • Uh oh.

  • B s.

  • Well, this is gonna be crazy.

  • Um oh, What have I done?

  • I guess I can't really share with you this about it.

  • Yeah, it's fine.

  • Just got a nice little Well, why is this year this is O.

  • B s.

  • It is red now.

  • This was green before.

  • That was green.

  • Before I did this view stats.

  • They're ago.

  • Ooh.

  • Okay, now it's bad.

  • Let me share this with you.

  • Look.

  • Sorry, Everyone, Hold on.

  • Here we go.

  • Okay, So that's the O.

  • B s stats.

  • Okay, I I'm now streaming again.

  • I've got the ah stats from O B s up here that you can see.

  • I don't have the chat open.

  • Give me a second to get that.

  • I mean, could I mean, I can't imagine that having the chat open on this computer was somehow causing a problem.

  • Gonna do that?

  • Every single life stream.

  • Okay, interestingly enough, quality seems to be good now.

  • Interesting.

  • Ok, here's the thing.

  • Uh, no, I'm recording two disc also.

  • Okay, well, I am going to hide these windows.

  • I am.

  • I have the chat up.

  • Have this up.

  • Okay, here we go.

  • Attempt number.

  • I don't know what this point.

  • Temp number three, I guess.

  • Uh oh.

  • I see a racy record.

  • We just have a look here, huh?

  • We're dropping some frames.

  • Network.

  • Yeah, it's the network.

  • Okay, Flack.

  • All right, everyone, uh, Alka brings up a good point.

  • Alka brings up a good point, which is that, um, there.

  • I think there's a backup ingest server on youtube that I could I don't know if you are seeing this, but I just switched to the yakup ingest server configuration.

  • Uh, and let's see, maybe don't blow your nose into the microphone.

  • That's a nice comment.

  • Uh, all right.

  • Since I switched to the backup server, Has that changed anything?

  • I don't know.

  • What time.

  • What?

  • Where you are in the time space continuum.

  • So if you're giving me comment ad, I need to know that you are hearing me talk about the backup ingest server and saying that it is still bad.

  • Yeah.

  • Okay.

  • Thank you.

  • Me?

  • I am.

  • Take a look at Oh, yeah, that's a lot of dropped frames network.

  • Okay, so what?

  • I guess I could try just coming back in, like, 1/2 an hour.

  • Maybe I'll just do that.

  • How about we try that?

  • I could just go on and do some stuff, and you will only be able to hear and barely be ableto watch.

  • Um, not sure what to do.

  • I got to make it just a music.

  • Help me think so.

  • I'm hearing from some spokes that it's gotten a little better.

  • I do see right now that I'm only getting more having 1/3 dropped frames.

  • Um, which is pretty good.

  • Um, so let me try.

  • Let me just do it a few things and I'm going to now ignore that this problem is happening, and I and I'm gonna turn off this monitoring, but I'm going to proceed.

  • Ping test.

  • Okay, hold on.

  • I'm gonna try one more thing.

  • All right.

  • Um, so thanks for your patience, everyone.

  • This this isn't going very well, but I'm gonna I'm gonna just try to give this, like, 15 or 20 minutes to do some content and see where we are.

  • Maybe my voice will start to get worse and only to stop.

  • Maybe the Internet won't have fixed itself, and only to stop.

  • But me just standing here doing nothing seems kind of pointless.

  • So, um, and just in case you're suggesting, why don't you restart blah, blah, blah.

  • Check your network connectivity restarted twice.

  • Network connectivity is good.

  • There's dropped frames from O.

  • B.

  • S.

  • Seems to be a network thing.

  • Who knows On what end where, but such is what's happening.

  • Okay, so I wanted to make a couple of announcements Number one.

  • Congratulations to the 2019 Processing Foundation.

  • Fellows, check out this medium article on medium dot com slash processing dash Foundation to see all the wonderful projects that are being funded by the processing foundation.

  • Um, this spring, Um and so I would love to tell you about all of these, but I'm just going to scroll through them like I've just done, and then I'm gonna close this window.

  • You'll be working fine.

  • I also wanted to mention that crossing foundation YouTube.

  • If you are not a subscriber, please subscribe to the processing foundations.

  • YouTube in particular, there is a video that just came out today, which is a three minute recap of processing community day in Los Angeles.

  • And to learn more about the Prospect Foundation and its mission and initiatives and Community Day, please check that video out.

  • Okay, Um, and stay tuned.

  • You let me actually click here to crossing for Nations Channel.

  • You can also check out the live stream archive.

  • You'll notice that it's 7.5 hours because this is just an archive of all of the talks from that day.

  • But Macha, who I work with on the coating train, and I are working too, put together edited versions of all the talks which will be posted soon, Sometime in the next few weeks.

  • Hopefully even so, stay tuned for that please subscribe to the process Foundation YouTube.

  • Consider also, you know, if you have the means and are able to if you can support the work The Crossing Foundation, by becoming a member once a year, I'll do do like a specific fundraiser on the coating train for the Prostate Foundation.

  • But process relation is a 51 C three tax exempt US nonprofit supported by some, uh, grants that we've been so lucky to get supported by the New York City Department of Education CS for all initiative and probably almost more primarily supported by people.

  • You, the viewers, perhaps of this channel, the people who use processing p five J s.

  • And if you want Thio become a member, you can go to hear all right?

  • Right now I'm just like, blah, blah, blah, blah, blah, blah to see if people are still saying lag.

  • Really?

  • All I've seen now the conferences looks stable.

  • Okay, so I wanted to mention enough.

  • Now I have another thing I want to mention, which is, uh so you may recall that I recently published coding challenge number 1 37 4 D open simplex noise loop.

  • Uh, I've talked about Perlin noise, classic Perla Noise or 1980 simplex noise from 2001.

  • There's actually a different improved Pearl annoys algorithm, also around 2001 that was separate from simplex noise.

  • I believe I've gotten some of this right.

  • Got some of it wrong, have conflated oversimplified Something's one of the mistakes I certainly made in this video was being, too.

  • Uh, I talked about moving a loop, looping noise in three deaths by moving a plane along like the path of a tourists, which isn't exactly what I'm doing because I'm actually using four dimensional space to loop.

  • But so there have been some really nice threads and comments explaining some of the things I got wrong in the comments of the video, so I highly encourage you to check that out.

  • I just want to highlight this one particular comment from, uh, Ralph to T.

  • Who writes noise is indeed a confusing topic.

  • So many terms I will try to clarify.

  • For those who are confused, there are many kinds of noise value.

  • Grady Int Wehrli, Gabor Gabor gab all this is one I have not heard of him ever looked at up wave lit, et cetera, When the algorithm uses a random number generator, it is probably value noise.

  • The Hugo Elias article, even though it's titled Perla Noise, is actually value noise.

  • So that's value noises.

  • When a bunch of random numbers are picked and sampled and interpolated and smooth value noise, that's a helpful clarification.

  • When the algorithm uses Grady Int the vectors on the grid points, it's called Grady it noise.

  • The most popular great noise algorithm is Perlin noise.

  • There are two it orations of pearl a noise.

  • The first is classical from version from 1983 and I believe this is the algorithm that's currently in processing and P five Gs.

  • When you call the noise function, then later can Perlin improved it by addressing a few issues to make what is known as improved Perla noise.

  • So we could actually look this up improved pearly noise, and we would find that here.

  • I believe this is improved noise reference implementation.

  • This is from a corresponding sig graft 2002 paper, which you confined right.

  • You're improving noise and then let's finish this comment out, then later Can Perlin in a photo.

  • Then in 2001 can Pearl unpublished simplex noise, which is different from the two other Perla noises but still is great noise.

  • So I assume that the first classic version and the improved noise are both operating.

  • I see that the lag is kind of happening again that both of those are operating ingredients are happening on a rectangular square grid noise on a simplistic grid or a grid grid of equal lateral triangles on dso Uh, there's an article about this that the author of this comment posts about improved Perla noise, which I will click on now.

  • And you can find that here.

  • So this is also a really nice reference, and it was nice while it was working, but it seems to be lagging again.

  • All right, so I'm getting some stuff off my chest.

  • Even in this lag states, be interesting.

  • Tow.

  • Watch this back later.

  • I love how the YouTube chat.

  • Moderation is smart enough to automatically flag comments that say, subscribe to a particular channel that Children big, nameless in addition to just, you know, uh, inappropriate language and that sort of thing.

  • Okay, sir, please restart your Mac.

  • I have tried that twice.

  • I don't think that's gonna do anything.

  • So I think I am not going to, uh, restart my Mac.

  • Some people are saying it's stable.

  • I'm gonna look at the control room.

  • Bad.

  • We're not receiving video.

  • It's so funny that I have this cold because it really just so apt.

  • It just couldn't be a better match.

  • The lag, the network lag and the the head congestion.

  • It just feels like the same thing.

  • That's all mixed together.

  • So it's It's kind of appropriate.

  • There's a bad lag problem, all right?

  • Oh, no.

  • What have I done?

  • What have I done?

  • I'm gonna close.

  • Don't make me pull this car over.

  • I will close the chat window and not look at it for the rest of the Lifestream behavior.

  • Well, I like that.

  • The audio's not lagging, cause at least you can hear me.

  • And in terms of dropped frames, All right, let's move on to the next topic of today.

  • Just gonna keep going.

  • And I'm probably gonna stop in about probably gonna stop in about 15 20 minutes.

  • If the the lag keeps going, there's there's one thing that I wanted to do.

  • Regardless of whether I'm live streaming, I could stop just as really kind of like practice.

  • Um, so let me talk about that a bit, okay?

  • Then I will take a break and come back a different time.

  • Maybe I do.

  • In my free Friday morning.

  • No, that would have been good.

  • Uh oh, boy.

  • Wow.

  • Now it says it's not even receiving any data.

  • Like it's completely stopped streaming.

  • Yeah.

  • Wow.

  • Look, it's back, but bad.

  • The Chad is really out of control, huh?

  • All right.

  • I'm sorry.

  • I'm gonna minimize the chat.

  • Uh, it's I will take a peek at it.

  • I'm going to just keep this lack channel open.

  • Um, the slack channel is for members of the coding train through YouTube or through patri on.

  • But to assume that my record to disk is working.

  • And I'm going thio talk through some stuff that I wantto think through and begin working on.

  • So I would suggest you maybe go do something else.

  • But if you wanna stick with me here, I'm gonna I'm gonna probably be here for, like, to talk through some of this stuff, okay?

  • I don't know that this will actually be a separate video, but let's give this a try.

  • Hi, it's It's me, Dan.

  • From the coding, right?

  • I mean, who else would it be?

  • Uh, I'm gonna just tell you about something that I'm working on that slowly over time on the channel, out of order.

  • I'm trying to work through an idea for a new playlist of videos.

  • If three idea is two heads and bolts skills around working with data and AP eyes in javascript both client side and server side, uh, I hope that this could be supported for people who are teaching courses on information, visualization, machine learning.

  • Uh, data, data, visualization, data art sell to people who are teaching for more fully fleshed out courses that involved project making and critique and dialogue.

  • But and maybe those people that I'm imagining in my head or teaching these courses could use some video resource is that could point their students towards that is somewhat generic and will give foundational skills.

  • So there's a get help depository.

  • Hopefully, by the time if you're watching this, this look totally different.

  • I'm working on a lot of ideas for this.

  • It's a get hub dot com slash coding train slash intro to data and AP eyes.

  • There is a bit of a description here and a bit of an outline.

  • So I am going to be working on this outline and making videos out of order and then kind of synthesizing stuff together and making an intro video.

  • And hopefully, by the end of April, beginning of May, the whole thing will be completed.

  • So that's what this playlist is.

  • Things are gonna appear out of order.

  • Give me feedback.

  • I might reduce some stuff, add some stuff.

  • But I would say the central place for you to give me feedback is to come over here and go thio issues and certainly could leave comments in this video.

  • But go over here to the issues and post your thoughts and ideas.

  • If you are a teacher who teaches this stuff and can give me ideas and thoughts about what would be specifically helpful that you would love to have his resource is a point your students towards That's in particular what I'm looking for.

  • Okay, Thanks very much.

  • And I'll see you in this playlist for some amount of time.

  • Should you choose to be here.

  • Goodbye.

  • Okay.

  • All right, boy, my watch just told me what four times five is.

  • Okay.

  • So I did that.

  • That's good.

  • I probably should have mentioned the learning only check check.

  • I have.

  • I'm looking for a message here.

  • It actually is telling me that the stream rate is good right now, which is kind of unbelievable.

  • I hesitate to check the chat, and I know that this could be fleeting.

  • Um, I just wanted to see something.

  • Uh um, You got it.

  • I got it.

  • Got it.

  • Got it.

  • So, um, anyway, I should also mention that this new playlist that I'm developing is supported by YouTube itself through the learning incentive grants.

  • So it's just like looking back about the male.

  • See what I'm supposed to say aloud to say.

  • Okay, um, I kind of wanna, like, check the chat again If I see the slack channel that it's stable.

  • Dare I pull up the chat?

  • So, uh, this will fit in somewhere in narrative.

  • See?

  • Totally figured that out yet.

  • So what I'm going to attempt to do right now is just do a short video tutorial like, remember, no more than 10 minutes is going to be 45 minutes.

  • I'm sure just about the function fetch Okay, let me make this bigger.

  • Okay?

  • Oh, hello to Egypt.

  • That's kind of amazing to me that there are people watching.

  • And Egypt.

  • Thank you, Amor.

  • If I'm apologies correctly.

  • Oh, it's red.

  • They see red.

  • It's the red.

  • That's not good.

  • Okay, I'm gonna just keep going with hello.

  • In this tutorial, I am going to talk about the function.

  • Fetch.

  • So the function.

  • Fetch the Java script function fetch, which is a Java script interface for accessing the manipulating parts of the http pipeline.

  • Whoa, I hold on starting over.

  • Hello?

  • In this video, I'm going to talk to you about the function fetch.

  • And this is a building block, a building block for many of the examples that I am going to demonstrate to you and show you how to do throughout the course of these videos.

  • Oh, I like that.

  • It's, uh, chat.

  • It's Kurtz, at least is lagging so that nobody can really see what I'm doing anyway.

  • Hello.

  • In this video, I'm going to talk to you about the function fetch.

  • And this function fetch will serve as a building block for a lot of the different examples and other topics that I talk to you throughout this series, working with data and AP eyes.

  • So what is fetch?

  • Okay, so it's a global method that you can call in Java script in the browser.

  • So, you know, maybe there are some browsers that don't yet support fetch.

  • And this is a consideration as you deploy a project to a large worldwide audience.

  • But for right now, we can kind of make the catch Is something we can right into our JavaScript code and fetch will fetch something.

  • It will get us.

  • It does this, http, hypertext transfer protocol thing to request data or actually you can use Fetch.

  • It seems counterintuitive to send data as well.

  • So hold on.

  • I have to I have to fix my whiteboard.

  • Um, hold on to fix the white board, take off the drop.

  • The message about all the drop frames.

  • Okay.

  • Okay.

  • Hey, take a minute to belittle.

  • Like coating train today is sponsored by the common cold.

  • I should have You did my microphone, but I decided to not meet my microphones.

  • There's you could hear the sounds, the authentic sounds of the common cold.

  • One thing I should recommend is when you have the common cold.

  • Consider trimming your beard because just everything's gross to fall growth, huh?

  • All right, let's diagram out.

  • Let's talk a bit more about the function.

  • Fetch that.

  • Yeah, fetches a function that you call by the keyword the function name fetch.

  • And you can give it more than one argument.

  • Now, the easiest way to use to give it one single argument.

  • And this is a path.

  • So it could be a path to our local file.

  • It could be or you are l path.

  • And you're saying, Hey, I would like this or this text data.

  • That's Jason data or this tabular data.

  • It's comma separated value file, any kind of data you can fetch it optionally you can give fetch a second argument, which is really like a bunch of configuration options.

  • So in the case where you actually want to use fetch to post data to say what you want to do is go into the body and pull the data out in some format that you want and I've made I premade I wrote a list here of the kinds of ways you can do that so you can get let might understand So maybe if you're just loading a text file, you're loading a Shakespeare play.

  • It's in a raw text file or your l.

  • You could then ask for that data as text.

  • If it's Jason Data, which is probably going to be the primary example.

  • The primary scenario and almost all of these examples throughout this you would ask for the data as Jason Blob is super interesting.

  • And actually, I think the first example I want to demonstrate to you today is used.

  • Blob, blob kind of means I just want a blob.

  • Just want the binaries, what the data itself.

  • So for an image that works really well because I just want, like the binary data, the pixels give that stuff to me, that's a blob.

  • There's also form data, which you could imagine if there's some if you're fetching date.

  • If your mouth don't say about that, huh?

  • There's also form data and Ray Puffer, and those might be some scenarios that we look at some point also.

  • But what?

  • How did how does this whole process happen?

  • So it's a two step process.

  • The first process is to give it the path, then the body comes back.

  • And then you need to ask for one of these things and the way to to sequence these events.

  • Everything in Java script with fetch happens a synchronously meaning you're waiting for something to happen and you'll get ah, call back an event.

  • But the fetch function works with something called Promises and promises a wave handling a synchronous events.

  • That's part of javascript E s six.

  • So if you've never encountered promises before, you could pause this video right now.

  • And I have a link it to some other videos I've made about promises and some other resource is and then come back.

  • But the key thing is that when when a promise is resolved, when the a synchronous event is completed, you then then you then it's funny that I'm writing the word.

  • Then you can then making me crazy just curious about the black.

  • It's green, it's green.

  • And by the way, they're people.

  • I see people in shat saying I can't handle all of the lag.

  • Please go do something else with your day.

  • This will be available later in archive form all sorts of stuff.

  • Um okay.

  • Huh?

  • I don't want to give myself more room here a wide with this way.

  • I don't want to start over now.

  • I have an idea of what I'm doing, but whatever.

  • Let me just least go back here.

  • So how do you handle this?

  • A synchronous event.

  • How do you write code that you that acts on the data when it's voted in the way that that works is by using the key word.

  • The function then.

  • And this is how you handled events with promises?

  • If so, if I say fetch, I give it.

  • Say I have a local file.

  • That's an image rainbow dot jpeg.

  • I can say dot then and I can add a So when this function here is going to be code that executes when it has finished loading the file, the tricky thing here is I don't have the data ready in a format that I want.

  • So once it's loaded, I have to write a function that then calls either blob or Jason or text in whatever to basically indicate what format I want the data to be prayer prepared for me in.

  • And that triggers another a synchronous event.

  • So I can say dot then and here is where I can actually use the data.

  • So here is when I wanted to say for this, convert the data to a blob which triggers another promise once it gets resolved, then I can actually maybe show the image.

  • So this is the narrative that do this with these, Even your keywords and JavaScript called a weight and a sink.

  • And I will show you that really quickly at the end of this video, because I might use that until the damn this is the process.

  • Fetch the pat fat fetch.

  • Give it a path to your data image tax, Jason et cetera.

  • Wait for the response.

  • Asked to prepare the data and warmth that you want, then get it in that format and use it.

  • It's red again.

  • Let's write some code.

  • So I'm doing something which I haven't done very much on my channel.

  • Absolute on.

  • Sorry.

  • Let me actually open this stuff up.

  • Okay, let's write some code.

  • So I'm doing something that I haven't really ever done on this channel before.

  • Communications say that happened in previous videos.

  • Let's write some code.

  • So I'm doing something that I do pretty rarely on this channel, which I just have a plane index dot html file and I'm gonna actually put my JavaScript in that file in a script tag.

  • Then the HTML elements are here, and there's no dependencies, So fetch is native.

  • You know, I am using the most recent version of the chrome browser, so fetch is available to be action.

  • So I also happened to have in the folder.

  • Let me just pull that up.

  • Uh, I happen to have in the directory with the index and html file a image called Rainbow Dodge.

  • A peg in this image is a also happened to have in the same directory as my HTML file a, um image file, public domain image file off a rainbow.

  • So this is the file that I load with the fetch function so we can see there's only thing right now is I have an H one element.

  • I haven't any image element.

  • The source of that image is empty.

  • The i d is rainbow, and I'm confident.

  • So if I go to the browser hit refresh, you can see I calm council log about to fetch your rating, bow and then it says, fetching him and touching.

  • Really say rainbow A rainbow.

  • Okay, so now what do I want to do?

  • I'm gonna call the fetch function, and I'm going to pass it rainbow dot jpeg.

  • So let's just refresh the page.

  • No, but how do I actually get the stuff?

  • So I said that I need to do Then write the ideas.

  • Now I'm going to say then and I'm gonna deal with getting the stuff here.

  • So let me just put a function in here.

  • Anonymous function.

  • And in here, I'm gonna say function has an argument.

  • I'm gonna call it response.

  • So this is the response.

  • Oh, shoot.

  • I'm in the wrong window.

  • Nobody can tell.

  • So let me put in an anonymous function, And in that function, I'm going to say console log.

  • Oh, and this function should take an argument.

  • That argument is response.

  • I'm gonna call it response to call it anything I want.

  • Like I'm even spelling it wrong.

  • I could call it, uh, you, Nikki, but I wouldn't call it response, because that makes sense.

  • That's where when?

  • When the promise has been resolved.

  • When I get the stuff.

  • So let's just say console long response.

  • Let's refresh the page and Look, there it is.

  • So there's lots of information.

  • Headers, the u R l All sorts of stuff in here does the body I need to figure out I need to parse through what's in the body of this response in a way that I can use and the way that I'm gonna do that is with the blob function.

  • So now I'm gonna say return response dot blob.

  • And I'm going to streamline this code if you're if you've done jobs, good programming before.

  • And you're like, why aren't you using the arrow syntax?

  • And, uh, I'm gonna streamline this code in in a minute, but I'm gonna kind of write it in the long winded way first.

  • So returning response dot blob means there's an US and I can change them.

  • And I think what I'd like to do is put this down.

  • Well, it's fine, I'm gonna say, and I'm going to write another.

  • There we go.

  • I'm gonna write another function.

  • Let's actually call it, uh, a blob here and let's say, console dot log blob.

  • So now you can see this is called a promise chain.

  • I'm fetching the rainbow.

  • Then when I get the response.

  • I'm convert blob of data.

  • And then let's look at that blob of data.

  • Let's look at what I got wrong.

  • What's the camera?

  • Went off, by the way, If you're just tuning in now, they working.

  • But I'm kind of pushing forward anyway, just cause I've got some stuff that I've got to do start getting on these videos.

  • Um, What's this is actually really just based on, um, the the example put out by Mozilla themselves.

  • Um, let's look at what they do in their basic fetch.

  • Same.

  • Uh oh.

  • I have to do your l create object.

  • Your l That's right.

  • Yeah.

  • Okay, so the true story here is that I can't just insert the blob to image dot source image, not source expects.

  • Ah, path.

  • Really?

  • Usually you put, you know, I could actually just put image dot source rainbow dot j.

  • You know, we're going to see that rainbow there, but that's not what I'm doing here.

  • I'm tryingto demonstrating this is a little bit absurd.

  • I don't demonstrate the process of loading the file and so, uh, loading the date of the file itself.

  • So I need to turn that data inch path itself.

  • And I think I can say that through your l create object your l and then image.

  • So I need to make a you Earl out of that blob.

  • So let's look at this and we can see.

  • There we go.

  • There's Theo image, and I was just Just so you see what it looks like?

  • I'm going to console log image dot source.

  • Uh, and you can see that's actually Well, now, hold on.

  • That's not what I want to do.

  • Just curious.

  • Does this do No.

  • Yeah, whatever.

  • Let me do this part again.

  • We pull up the documentation page, so we have that.

  • Sorry.

  • Um, so the truth that the story here it's green again, their rooms and I look over his green and people can actually maybe see me.

  • The true story here is that I can't simply just assign a blob of data to an HTML elements source property.

  • So what I need to do here is I actually need to create a u r l out of that data.

  • And in fact, that's what's expected there.

  • I mean, I could actually just put the string rainbow dot j peg.

  • Since the files there and that's a path.

  • But that's not what I'm doing here.

  • I'm trying to demonstrate the fetch function, so I'm loading a local file, getting the data, soc with that file and then turning it back into a Eurail path that I can insert into a dom element.

  • So the way to do that is with a particular function called Create Object, Earl.

  • So this function is a function that takes a file blob or media source object and creates an object.

  • You're ill from it.

  • So now I can say, uh, you are el Jor el dot Create object.

  • You are l blob.

  • And now this is the whole process.

  • Fetch the rainbow, turn the wrist, earn the body of the response from that fetch operation to a blob of data, turn that blob of data into a your L and insert it into an image elements source attributes.

  • And here we go back to here a All right, so this is the whole process.

  • But let's do a cups here to streamline the code.

  • I could have written it the way I'm about to show you originally, but I like to step through things incrementally.

  • So one thing I could do is I could use a row syntax, which is a shorthand way of defining a function instead of using the keyword function I can say equals equals greater than we go, right.

  • And then here I can also do the same thing with the Blob.

  • So this is a way of sorts streamlining shorthand, the function.

  • Now, another thing I could do is I don't actually need to have this console dot log so I can actually remove these curly brackets and right, and and remove the return key word.

  • And actually, just write it like this.

  • So when this is a really nice shorthand, any error that occurs throughout this entire process will end up down here.

  • So I don't have to have a sandal ing thing for every single one.

  • And you thought this video is over.

  • Let's make one more small improvement on this.

  • Let's actually run this to make sure it's working.

  • 00 Unexpected is token air, so I'm always making syntax errors when I'm writing code.

  • This, uh, this needs a parentheses.

  • Write one more parentheses there because oh, and this should look like this.

  • Ah, there we go.

  • So this was ost function.

  • I was so close.

  • That was way off What I just wrote there, so hopefully I didn't confuse you there.

  • But sometimes I leave this nice for you to see the mistakes and kind of maybe correct them in your head while you're watching.

  • But, uh, so this is I'm taking the error and in fact, cause this is just one line of code, I could also streamline this and get rid of this semi colon.

  • And now this is our final final results.

  • For one more thing that I'm gonna do, I'm gonna fetch the rainbow.

  • I'm gonna turn the response and told him to get the blob inserted in the dime element.

  • And any error happens.

  • Do that.

  • Now I'm gonna refresh and look, there we go.

  • We affect the rainbow.

  • Now, you know what fetch does just because I can.

  • I'm getting a little bit longer to do one more thing.

  • If I wanted Thio, I could write my own function called Fetch Rainbow.

  • Find that function as a sink and I have a set of videos that goes through how this works in a bit more detail.

  • A six or a sink function fetch rainbow.

  • Um And so you I'll refer you to those in this description of this video as well.

  • But basically what this allows me to just call fetch, using the keyword await.

  • So awake is a key word that allows me to write a sequence of that return promises without using dot Then so I can say just constant response equals Fetch rainbow.

  • This is an asynchronous function.

  • So I need to say await.

  • Then I can say constant blob equals await response dot blob.

  • And then I can just do these last two pieces right here and now we can see this is exam code, but I'm using a weight and the a sink and await keywords.

  • So I'm writing an a sink function called Fetch Rainbow.

  • I fell.

  • I converted to a blob.

  • Then I inserted into the dom element.

  • And let's just see if this works.

  • We still have all right.

  • So hopefully this video gives you a sense of what the fetch function is, how you use it, how it integrates with javascript promises as well as and wait keywords.

  • And this will give you the sort of foundational element for when fetch appears in all sorts of other examples and tutorials that involved Ephraim and a P I or some local file or other things.

  • And in fact, even though fetch is something that's just here in the browser, I'm going to show you fetch in service side program with Java script in No Duchess as well in a future video.

  • Thanks for watching.

  • Um all right, let me say I probably should have added the error handling here.

  • Yeah, uh, let me see.

  • Well, it's still the law.

  • I thought maybe the lag would sort of clean itself up.

  • Um, yeah, I've tried to fix s snake ass.

  • Did he try to fix it?

  • I tried to fix the lag many times.

  • I think it has to do with my cold.

  • Frankly, um, so let me I'm gonna, um And I wonder how I'm gonna add a little bit of stuff.

  • One more thing about writing your own asynchronous function using the A sink keyword this function, right?

  • Everything's happening.

  • A synchronously in here.

  • This is really just what's a syntactic sugar To make the way you write your code Easier to read and follow.

  • But ultimately, it's all about asynchronous events.

  • So this in fact by definition automatically returns a promise.

  • So I could just do something like, say, return.

  • Yea, right.

  • This is very silly, but I'm just gonna return the word.

  • Yea.

  • And then I could add if I wanted to check to have an event for when this finishes I can actually say that.

  • Then I can say response console dot log response and then I can also say dot Catch Go to another line, please.

  • I could say dot Catch an error console unsold out log error.

  • So this is a very simple way of doing some type of error handling where I have now written the a sink the ai think function to use fetch to use vetch when it's done, I couldn't return more information, right?

  • I could actually design a whole sort of like protocol and do stuff here, but I'm just want to see that it worked to console along that or if there was an error to console long the error and I should get in the habit of saying console dot error instead of counsel dot log for air itself.

  • Okay, let's run this Yea.

  • And still works.

  • All right, so this video.

  • Hopefully what I've done now is shown you how to use the fetch function.

  • What is the fetch function?

  • What does it do?

  • How it integrates with job script promises as well as the A sink and await keyword.

  • These are not the easiest topics to wrap your head around, so you might want to refer to some of the supplementary material about promises and a sink await.

  • But this function fetch will serve the basis for so many other examples that you'll see throughout this series whether it's loading, you know.

  • Ah C s v file of some tabular data.

  • It's loading a Jason file from an A p I u R L.

  • You're going to need to fetch function.

  • And in fact, the fetch function works.

  • You're a very loud, piercing, high pitched noise.

  • And in fact, the fetch function also can be used in node.

  • Now it's not natively available in node.js like it is in the browser, but there's ways of gaining access to it.

  • And at some point when

Good morning.

字幕と単語

ワンタップで英和辞典検索 単語をクリックすると、意味が表示されます

B1 中級

ライブストリーム #171ノイズループを片付ける時が来た (Live Stream #171: Time to put away the noise loops!)

  • 0 0
    林宜悉 に公開 2021 年 01 月 14 日
動画の中の単語