8 Kasım 2016 Salı

Redux store fonksiyonları

The store binds together the three principles of redux. It holds the current applications state object. It lets you dispatch actions. When you create it, you need to specify the reducer that tells how state is updated with actions.

The store has three important methods.
The first method of store is "getState". It retrieves the current state of the redux store.
The second and the most commonly used store method is called "dispatch". And it lets you dispatch actions that changes the state of your application.
Third redux store method is called "subscribe". It lets you register a callback that the redux store will call anytime an action has been dispatched.



Store, redux’ın üç prensibini birleştirir. Uygulamanın state objesini tutar. Action’ları dispatch eder (dağıtır). Store’u oluştururken state’lerin action’larla nasıl güncelleneceği belirtilmelidir. (createStore function’ına parametre olarak reducer verilmelidir.)

Store’un 3 önemli yöntemi/metodu/fonksiyonu vardır.
İlki “getState”tir. Redux store’unun mevcuttaki state’ini getirir.
İkincisi ve en çok kullanılanı “dispatch”tir. Uygulamadaki state’leri değiştirecek action’ları dağıtır.
Üçüncüsü “subscribe”dır. Store’a bir callback ekler. Bir action çalıştığında redux store tarafında çağrılır.

ve devamındaki videolar.

Redux prensipleri

First principle of redux; everything that changes in your application including the data and the ui state is contained in a single object. we call that state or state tree. (store)

Second principle of redux is that the state tree is read only. You cannot modify or write through it.

The pure functions are the functions whose return value depends only on the values of arguments. They do not have any observable side affects. They do not modify the values passed to them.

Impure functions may call the database or the network. They may have side affects. They may operate on the DOM. They may override the values passed to them.

The third principle of redux is some functions that makes the changes on states have to be pure in redux. (Reducer must be pure.)



Redux’ın ilk prensibi, uygulama içindeki herhangi bir data olsun veya ui olsun, olan herhangi bir değişikliğinin tek bir obje içerisinde tutulmasıdır. Buna “state” veya “state tree” denir.

Redux’ın ikinci prensibi, “state”in sadece okunur olması, üzerinde herhangi bir değişiklik yapılamaması veya üzerine yazılamamasıdır.

“Pure functions (Katışıksız fonksiyonlar)” sadece aldığı parametreleri kullanarak değer dönen metotlardır. Bu fonksiyonların herhangi bir yan etkisi yoktur. Fonksiyon, kendisine geçirilen parametreleri değiştirmez.

“Impure functions (karışık fonlsiyonlar)” database’den veya network’ten bilgi çekiyor olabilir. Yan etkileri olabilir, DOM’u yönetebilir. Kendilerine geçirilen parametreleri değiştirebilirler.

Redux’ın üçüncü prensibi state’lerde değişiklik yapan fonksiyonlar “pure function” olmalı. (Reducer pure function olmalı.)


ve devamındaki videolar.