In the last video we created our first New Stream we're going to go through the process of creating
one more Stream right here so I can put in a quick title of stream and a description of here's some
stream and I've got my network request Lague open again.
I'm going to submit this and then check out the post requests that we had created.
All right.
So when I inspect this thing I'm going to open up the preview tab and you'll notice that we get back
a response right here of the description the title and the newly assigned ID from the API server.
So at this point we've basically got this new record that reflects stream that we've just created coming
back and the response that we made over to that API.
So when we start to think about that and think about our actual creator back you're inside the actions
index file.
I think that we need to somehow get a handle on the response that comes back from that post request
because it contains the actual saved record of the stream that we just created.
So inside a create stream I'm going to put the weight keyword on there will say cancer response equals
a weight stream's up post.
So now that we have a handle on the stream that just got created we're probably going to want to dispatch
an action with a payload of that stream and then we can eventually create a reducer and pick up that
stream that was created and save it inside there or whatever it is we want to do.
So in order to dispatch an action we first need to have a type.
Remember we now have this idea of these constant type value.
So we define inside of our types file.
So let's open up that type's file rate a new type inside there and then make sure we import it into
this indexed file.
So here is types.
I'm going to create a new type of.
How about create stream and then I'll give this a type of create stream for the actual string value.
OK so that looks good.
So now we'll save this a flip back or two that actions index as file and I will import create stream
at the top.
Now we have everything we need back down inside the Create stream action creator itself.
After we get our response I'm going to dispatch an action with that type of create stream for the payload.
I'm going to make sure that I take response data and return it with the data right here because remember
when we get a response back from ASIO's the response object has a ton of information about the response
but we only care about the information that was returned inside the request.
So that's why we are only returning response to data inside that pallet property.
OK so looks great.
Now the only thing here is we don't have a producer so we can definitely go and create ever douceur
that's going to essentially save the stream that we just created inside of our application level States.
But before we do I want to take a quick pause and then mention something kind of interesting about all
the action creators that you and I are going to end up creating.
So quick pause you know I'll see you in just a minute.