Afrikaans
Akan
Albanian
Amharic
Arabic
Armenian
Azerbaijani
Basque
Belarusian
Bemba
Bengali
Bihari
Bosnian
Breton
Bulgarian
Cambodian
Catalan
Cebuano
Cherokee
Chichewa
Chinese (Simplified)
Chinese (Traditional)
Corsican
Croatian
Czech
Danish
Dutch
English
Esperanto
Estonian
Ewe
Faroese
Filipino
Finnish
French
Frisian
Ga
Galician
Georgian
German
Greek
Guarani
Gujarati
Haitian Creole
Hausa
Hawaiian
Hebrew
Hindi
Hmong
Hungarian
Icelandic
Igbo
Indonesian
Interlingua
Irish
Italian
Japanese
Javanese
Kannada
Kazakh
Kinyarwanda
Kirundi
Kongo
Korean
Krio (Sierra Leone)
Kurdish
Kurdish (Soranรฎ)
Kyrgyz
Laothian
Latin
Latvian
Lingala
Lithuanian
Lozi
Luganda
Luo
Luxembourgish
Macedonian
Malagasy
Malay
Malayalam
Maltese
Maori
Marathi
Mauritian Creole
Moldavian
Mongolian
Myanmar (Burmese)
Montenegrin
Nepali
Nigerian Pidgin
Northern Sotho
Norwegian
Norwegian (Nynorsk)
Occitan
Oriya
Oromo
Pashto
Polish
Portuguese (Brazil)
Portuguese (Portugal)
Punjabi
Quechua
Romanian
Romansh
Runyakitara
Russian
Samoan
Scots Gaelic
Serbian
Serbo-Croatian
Sesotho
Setswana
Seychellois Creole
Shona
Sindhi
Sinhalese
Slovak
Slovenian
Somali
Spanish
Spanish (Latin American)
Sundanese
Swahili
Swedish
Tajik
Tamil
Tatar
Telugu
Thai
Tigrinya
Tonga
Tshiluba
Tumbuka
Turkish
Turkmen
Twi
Uighur
Ukrainian
Urdu
Uzbek
Vietnamese
Welsh
Wolof
Xhosa
Yiddish
Yoruba
Zulu
So in the bookstore, I'll now add a product stash store, Jaspal, of course, you can name this whatever
you want and here I'll import in it store from the store, Jaspal.
Now you're all to configure a store function, which is not getting any arguments, but where we can
now set up our actions and our initial state and then I'll call in in its store and passed it data to
it.
So the first thing is my actions, and that should be an object.
And now here you have some identifiers like, let's say toggle fav.
That's a property name here.
And the value, as I mentioned earlier, should be a function where you get your current state, so
Curre state.
And you return the part of the state you want to update.
So here I return.
And new object with a product key, because you're a plan on updating the products.
Where I get my curse state products.
And keep in mind, that state always is this global state thing, which could manage different kinds
of state.
But the way we set up this despatching is that we will update the global state with our return value
of when we call our action, but merged it with the existing states.
So here we only have to return what we want to change.
And here I want to return a new object with a product key because I want to change my products with
current state products.
But of course, now here I want to switch to favorite status, so I'll use the same logic as before,
which we already set up multiple times, for example, here in the products context file in there.
It's this logic here for creating an updated list of products.
So do that in here, and current product list is now simply current state dot product, so that's our
current list of products.
So let's replace all of that with current state products and the product I.D. here.
That's, of course, something we all need.
So actually, we should alter this action here and not just expect the global state.
But you're also a product I.D., let's say, so that we can use that here to then here I return my products.
Key with updated products as a value now this is my actions object, and we'll have to make sure that
this I.D. thing is handled soon.
But now, for now, the syste actions object and now in its store can be called by forwarding our actions
object, which will be registered in our global actions, object in the store.
And then an initial state where I also want to have some products.
And their products, of course, can be taken from the products context file.
It's this array of products.
Let's copy it from there and move it into the product store file here as an array.
So now we have that file which initializes our store with our actions and our starting state, our starting
object with our starting list of products.
Now I will export this configure store function where all of this is happening.
So this function here so we can use it.
And let's briefly go back to the storage as followed and also make sure that when an action is dispatched
and we forward the global state, we also can forward any value, any payload that is passed along with
the action.
So here to dispatch function should not just be getting an action identifier, but also, let's say
a payload so that we can forward that payload to our action function as well.
And payload can now be an object or just a string number, whatever you need.
And for example, that allows us to set up action here in the product store file where we expect to
get a product that would be the payload.
We then have to pass along when we call dispatch.
And that's the missing thing.
We said all of that up, but we're not using our custom store here.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.