Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitbaa57d7

Browse files
committed
docs(readme): add new UWP package
1 parent19694b4 commitbaa57d7

File tree

1 file changed

+42
-40
lines changed

1 file changed

+42
-40
lines changed

‎README.md‎

Lines changed: 42 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@
44

55
[![CodeFactor](https://www.codefactor.io/repository/github/odonno/reduxsimple/badge)](https://www.codefactor.io/repository/github/odonno/reduxsimple)
66

7-
| Package| Versions|
8-
| -------| --------|
9-
| ReduxSimple|[![NuGet](https://img.shields.io/nuget/v/ReduxSimple.svg)](https://www.nuget.org/packages/ReduxSimple/)|
10-
| ReduxSimple.Entity|[![NuGet](https://img.shields.io/nuget/v/ReduxSimple.Entity.svg)](https://www.nuget.org/packages/ReduxSimple.Entity/)|
7+
| Package| Versions|
8+
| ---------------------------| ---------------------------------------------------------------------------------------------------------------------------------------|
9+
| ReduxSimple|[![NuGet](https://img.shields.io/nuget/v/ReduxSimple.svg)](https://www.nuget.org/packages/ReduxSimple/)|
10+
| ReduxSimple.Entity|[![NuGet](https://img.shields.io/nuget/v/ReduxSimple.Entity.svg)](https://www.nuget.org/packages/ReduxSimple.Entity/)|
11+
| ReduxSimple.Uwp|[![NuGet](https://img.shields.io/nuget/v/ReduxSimple.Uwp.svg)](https://www.nuget.org/packages/ReduxSimple.Uwp/)|
1112
| ReduxSimple.Uwp.RouterStore|[![NuGet](https://img.shields.io/nuget/v/ReduxSimple.Uwp.RouterStore.svg)](https://www.nuget.org/packages/ReduxSimple.Uwp.RouterStore/)|
12-
| ReduxSimple.Uwp.DevTools|[![NuGet](https://img.shields.io/nuget/v/ReduxSimple.Uwp.DevTools.svg)](https://www.nuget.org/packages/ReduxSimple.Uwp.DevTools/)|
13+
| ReduxSimple.Uwp.DevTools|[![NuGet](https://img.shields.io/nuget/v/ReduxSimple.Uwp.DevTools.svg)](https://www.nuget.org/packages/ReduxSimple.Uwp.DevTools/)|
1314

1415
>Simple Stupid Redux Store using Reactive Extensions
1516
@@ -23,12 +24,12 @@ You can follow this link: https://www.microsoft.com/store/apps/9PDBXGFZCVMS
2324

2425
##Getting started
2526

26-
Like the original Redux library, you will have to initialize a new`State` when creating a`Store` + you will create`Reducer` functions each linked to an`Action` which will possibly update this`State`.
27+
Like the original Redux library, you will have to initialize a new`State` when creating a`Store` + you will create`Reducer` functions each linked to an`Action` which will possibly update this`State`.
2728

2829
In your app, you can:
2930

30-
*`Dispatch` new`Action` to change the`State`
31-
* and listen to events/changes using the`Subscribe` method
31+
-`Dispatch` new`Action` to change the`State`
32+
- and listen to events/changes using the`Subscribe` method
3233

3334
You will need to follow the following steps to create your own Redux Store:
3435

@@ -70,17 +71,17 @@ public static class Reducers
7071
(state,action)=>state.With(new {Pages=state.Pages.Add(action.PageName) })
7172
),
7273
On<GoBackAction,RootState>(
73-
state=>
74+
state=>
7475
{
7576
varnewPages=state.Pages.RemoveAt(state.Pages.Length-1);
76-
returnstate.With(new {
77+
returnstate.With(new {
7778
CurrentPage=newPages.LastOrDefault(),
7879
Pages=newPages
7980
});
8081
}
8182
),
8283
On<ResetAction,RootState>(
83-
state=>state.With(new {
84+
state=>state.With(new {
8485
CurrentPage=string.Empty,
8586
Pages=ImmutableArray<string>.Empty
8687
})
@@ -134,6 +135,7 @@ Store.ObserveAction<NavigateAction>().Subscribe(_ =>
134135

135136
Store.Select(state=>state.CurrentPage)
136137
.Where(currentPage=>currentPage==nameof(Page1))
138+
.UntilDestroyed(this)
137139
.Subscribe(_=>
138140
{
139141
// TODO : Handle event when the current page is now "Page1"
@@ -146,7 +148,7 @@ Store.Select(state => state.CurrentPage)
146148
<summary>Reducers</summary>
147149
<br>
148150

149-
Reducers are pure functions used to create a new`state` once an`action` is triggered.
151+
Reducers are pure functions used to create a new`state` once an`action` is triggered.
150152

151153
###Reducers on action
152154

@@ -159,17 +161,17 @@ return new List<On<RootState>>
159161
(state,action)=>state.With(new {Pages=state.Pages.Add(action.PageName) })
160162
),
161163
On<GoBackAction,RootState>(
162-
state=>
164+
state=>
163165
{
164166
varnewPages=state.Pages.RemoveAt(state.Pages.Length-1);
165-
returnstate.With(new {
167+
returnstate.With(new {
166168
CurrentPage=newPages.LastOrDefault(),
167169
Pages=newPages
168170
});
169171
}
170172
),
171173
On<ResetAction,RootState>(
172-
state=>state.With(new {
174+
state=>state.With(new {
173175
CurrentPage=string.Empty,
174176
Pages=ImmutableArray<string>.Empty
175177
})
@@ -183,9 +185,9 @@ Sub-reducers also known as feature reducers are nested reducers that are used to
183185

184186
The`CreateSubReducers` function helps you to create sub-reducers. This function has a few requirements:
185187

186-
* a`Selector` - to be able to access the value of the current nested state
187-
* a`Reducer` - to explicitly detail how to update the parent state given a new value for the nested state
188-
* and the list of reducers using`On` pattern
188+
- a`Selector` - to be able to access the value of the current nested state
189+
- a`Reducer` - to explicitly detail how to update the parent state given a new value for the nested state
190+
- and the list of reducers using`On` pattern
189191

190192
First you need to create a new state lens for feature/nested states:
191193

@@ -230,7 +232,7 @@ Remember that following this pattern, you can have an infinite number of layers
230232

231233
Based on what you need, you can observe the entire state or just a part of it.
232234

233-
Note that every selector is a*memoized selector* by design, which means that a next value will only be subscribed if there is a difference with the previous value.
235+
Note that every selector is a_memoized selector_ by design, which means that a next value will only be subscribed if there is a difference with the previous value.
234236

235237
###Full state
236238

@@ -256,7 +258,7 @@ Store.Select(state => state.CurrentPage)
256258

257259
###Simple selectors
258260

259-
Simple selectors are like functions but the main benefits are that they can be reused in multiple components and they can be reused to create other selectors.
261+
Simple selectors are like functions but the main benefits are that they can be reused in multiple components and they can be reused to create other selectors.
260262

261263
```csharp
262264
publicstaticISelectorWithoutProps<RootState,string>SelectCurrentPage=CreateSelector(
@@ -286,7 +288,7 @@ public static ISelectorWithoutProps<RootState, bool> SelectHasPreviousPage = Cre
286288

287289
###Reuse selectors - with props
288290

289-
You can also use variables out of the store to create a new selector.
291+
You can also use variables out of the store to create a new selector.
290292

291293
```csharp
292294
publicstaticISelectorWithProps<RootState,string,bool>SelectIsPageSelected=CreateSelector(
@@ -333,9 +335,9 @@ Side effects are functions that runs outside of the predictable State -> UI cycl
333335

334336
When you work with asynchronous tasks (side effects), you can follow the following rule:
335337

336-
* Create 3 actions - a start action, a`fulfilled` action and a`failed` action
337-
* Reduce/Handle response on`fulfilled` action
338-
* Reduce/Handle error on`failed` action
338+
- Create 3 actions - a start action, a`fulfilled` action and a`failed` action
339+
- Reduce/Handle response on`fulfilled` action
340+
- Reduce/Handle error on`failed` action
339341

340342
Here is a concrete example.
341343

@@ -365,14 +367,14 @@ public static Effect<RootState> GetTodos = CreateEffect<RootState>(
365367
()=>Store.ObserveAction<GetTodosAction>()
366368
.Select(_=>_todoApi.GetTodos())
367369
.Switch()
368-
.Select(todos=>
370+
.Select(todos=>
369371
{
370372
returnnewGetTodosFulfilledAction
371373
{
372374
Todos=todos.ToImmutableList()
373375
};
374376
})
375-
.Catch(e=>
377+
.Catch(e=>
376378
{
377379
returnObservable.Return(
378380
newGetTodosFailedAction
@@ -434,14 +436,14 @@ It will then fires an `UndoneAction` event you can subscribe to.
434436
Store.Select()
435437
.Subscribe(_=>
436438
{
437-
// TODO : Handle event when the State changed
439+
// TODO : Handle event when the State changed
438440
// You can observe the previous state generated or...
439441
});
440442

441443
Store.ObserveUndoneAction()
442444
.Subscribe(_=>
443445
{
444-
// TODO : Handle event when an Undo event is triggered
446+
// TODO : Handle event when an Undo event is triggered
445447
// ...or you can observe actions undone
446448
});
447449
```
@@ -512,7 +514,7 @@ You can then handle the reset event on your application.
512514
Store.ObserveReset()
513515
.Subscribe(_=>
514516
{
515-
// TODO : Handle event when the Store is reset
517+
// TODO : Handle event when the Store is reset
516518
// (example: flush navigation history and restart from login page)
517519
});
518520
```
@@ -525,7 +527,7 @@ Store.ObserveReset()
525527

526528
When dealing with entities, you often repeat the same process to add, update and remove entity from your collection state. With the`ReduxSimple.Entity` package, you can simplify the management of entities using the following pattern:
527529

528-
1. Start creating an`EntityState` and an`EntityAdapter`
530+
1. Start creating an`EntityState` and an`EntityAdapter`
529531

530532
```csharp
531533
publicclassTodoItemEntityState :EntityState<TodoItem,int>
@@ -619,12 +621,12 @@ protected override void OnLaunched(LaunchActivatedEventArgs e)
619621

620622
![./images/devtools.PNG](./images/devtools.PNG)
621623

622-
Sometimes, it can be hard to debug your application. So there is a perfect tool called Redux DevTools which help you with that:
624+
Sometimes, it can be hard to debug your application. So there is a perfect tool called Redux DevTools which help you with that:
623625

624-
* list all dispatched actions
625-
* payload of the action and details of the new state after dispatch
626-
* differences between previous and next state
627-
* replay mechanism (time travel)
626+
- list all dispatched actions
627+
- payload of the action and details of the new state after dispatch
628+
- differences between previous and next state
629+
- replay mechanism (time travel)
628630

629631
####For UWP
630632

@@ -647,11 +649,11 @@ await Store.OpenDevToolsAsync();
647649

648650
####[mhusainisurge](https://github.com/mhusainisurge)
649651

650-
* Observe partial state[#7](https://github.com/Odonno/ReduxSimple/pull/7)
651-
*`ReduxStoreWithHistory`[#9](https://github.com/Odonno/ReduxSimple/pull/9)
652-
*`Reset()` method on`ReduxStore`[#14](https://github.com/Odonno/ReduxSimple/pull/14)
653-
* XML documentation of C# classes and attributes[#16](https://github.com/Odonno/ReduxSimple/pull/16)
652+
- Observe partial state[#7](https://github.com/Odonno/ReduxSimple/pull/7)
653+
-`ReduxStoreWithHistory`[#9](https://github.com/Odonno/ReduxSimple/pull/9)
654+
-`Reset()` method on`ReduxStore`[#14](https://github.com/Odonno/ReduxSimple/pull/14)
655+
- XML documentation of C# classes and attributes[#16](https://github.com/Odonno/ReduxSimple/pull/16)
654656

655657
####[ltjax](https://github.com/ltjax)
656658

657-
* Improvements on sub-reducers, with State lenses[#75](https://github.com/Odonno/ReduxSimple/pull/75)
659+
- Improvements on sub-reducers, with State lenses[#75](https://github.com/Odonno/ReduxSimple/pull/75)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp