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

Commitf314198

Browse files
committed
feat: create UntilDestroyed operator
1 parent154b235 commitf314198

File tree

10 files changed

+131
-11
lines changed

10 files changed

+131
-11
lines changed

‎ReduxSimple.Uwp.Samples/Counter/CounterPage.xaml.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
usingMicrosoft.Toolkit.Uwp.UI.Animations;
22
usingReduxSimple.Uwp.DevTools;
33
usingReduxSimple.Uwp.Samples.Components;
4-
usingReduxSimple.Uwp.Samples.Extensions;
54
usingSystem;
65
usingSystem.Reactive.Linq;
76
usingWindows.System;
@@ -21,6 +20,7 @@ public CounterPage()
2120

2221
// Observe changes on state
2322
Store.Select(SelectCount)
23+
.UntilDestroyed(this)
2424
.Subscribe(count=>
2525
{
2626
CounterValueTextBlock.Text=count.ToString();

‎ReduxSimple.Uwp.Samples/Pokedex/PokedexPage.xaml.cs‎

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,27 +26,30 @@ public PokedexPage()
2626
Store.Select(
2727
CombineSelectors(SelectLoading,SelectIsPokedexEmpty)
2828
)
29-
.ObserveOnDispatcher()
30-
.Subscribe(x=>
31-
{
32-
var(loading,isPokedexEmpty)=x;
29+
.ObserveOnDispatcher()
30+
.UntilDestroyed(this)
31+
.Subscribe(x=>
32+
{
33+
var(loading,isPokedexEmpty)=x;
3334

34-
OpenPokedexButton.ShowIf(!loading&&isPokedexEmpty);
35+
OpenPokedexButton.ShowIf(!loading&&isPokedexEmpty);
3536

36-
GlobalLoadingProgressRing.IsActive=loading&&isPokedexEmpty;
37-
GlobalLoadingProgressRing.ShowIf(loading&&isPokedexEmpty);
38-
RootStackPanel.ShowIf(!isPokedexEmpty);
39-
});
37+
GlobalLoadingProgressRing.IsActive=loading&&isPokedexEmpty;
38+
GlobalLoadingProgressRing.ShowIf(loading&&isPokedexEmpty);
39+
RootStackPanel.ShowIf(!isPokedexEmpty);
40+
});
4041

4142
Store.Select(SelectSuggestions,5)
4243
.ObserveOnDispatcher()
44+
.UntilDestroyed(this)
4345
.Subscribe(suggestions=>
4446
{
4547
AutoSuggestBox.ItemsSource=suggestions;
4648
});
4749

4850
Store.Select(SelectPokemon)
4951
.ObserveOnDispatcher()
52+
.UntilDestroyed(this)
5053
.Subscribe(pokemon=>
5154
{
5255
PokemonPanel.ShowIf(pokemon.HasValue);
@@ -57,6 +60,7 @@ public PokedexPage()
5760

5861
Store.Select(SelectErrors)
5962
.ObserveOnDispatcher()
63+
.UntilDestroyed(this)
6064
.Subscribe(errors=>
6165
{
6266
ErrorsListView.ItemsSource=errors;

‎ReduxSimple.Uwp.Samples/ReduxSimple.Uwp.Samples.csproj‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,10 @@
322322
<Project>{1a224f30-719c-411c-9876-5c9bd99ea3c6}</Project>
323323
<Name>ReduxSimple.Uwp.RouterStore</Name>
324324
</ProjectReference>
325+
<ProjectReferenceInclude="..\ReduxSimple.Uwp\ReduxSimple.Uwp.csproj">
326+
<Project>{981e7664-7703-4f24-93ec-073a913643e0}</Project>
327+
<Name>ReduxSimple.Uwp</Name>
328+
</ProjectReference>
325329
<ProjectReferenceInclude="..\ReduxSimple\ReduxSimple.csproj">
326330
<Project>{bd02f8db-a1e4-409c-9d69-3dfb2e84e786}</Project>
327331
<Name>ReduxSimple</Name>

‎ReduxSimple.Uwp.Samples/TicTacToe/TicTacToePage.xaml.cs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public TicTacToePage()
2727
Store.Select(
2828
CombineSelectors(SelectGameEnded,SelectWinner)
2929
)
30+
.UntilDestroyed(this)
3031
.Subscribe(x=>
3132
{
3233
var(gameEnded,winner)=x;
@@ -45,6 +46,7 @@ public TicTacToePage()
4546
});
4647

4748
Store.Select(SelectCells)
49+
.UntilDestroyed(this)
4850
.Subscribe(cells=>
4951
{
5052
for(inti=0;i<cells.Length;i++)

‎ReduxSimple.Uwp.Samples/TodoList/TodoListPage.xaml.cs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public TodoListPage()
2626

2727
// Observe changes on state
2828
Store.Select(SelectFilter)
29+
.UntilDestroyed(this)
2930
.Subscribe(filter=>
3031
{
3132
switch(filter)
@@ -47,6 +48,7 @@ public TodoListPage()
4748
});
4849

4950
Store.Select(SelectItems)
51+
.UntilDestroyed(this)
5052
.Subscribe(items=>
5153
{
5254
if(TodoItemsListView.ItemsSource!=advancedCollectionView)

‎ReduxSimple.Uwp/Operators.cs‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
usingSystem;
2+
usingSystem.Reactive.Linq;
3+
usingWindows.System;
4+
usingWindows.UI.Xaml;
5+
usingWindows.UI.Xaml.Controls;
6+
usingWindows.UI.Xaml.Controls.Primitives;
7+
8+
namespaceReduxSimple.Uwp
9+
{
10+
publicstaticclassOperators
11+
{
12+
/// <summary>
13+
/// Automatically unsubscribe the current Observable when the page is unloaded.
14+
/// </summary>
15+
/// <typeparam name="T">Type of the data inside the current Observable.</typeparam>
16+
/// <param name="observable">The current Observable.</param>
17+
/// <param name="page">The page linked to the current Observable.</param>
18+
/// <returns>The current Observable.</returns>
19+
publicstaticIObservable<T>UntilDestroyed<T>(thisIObservable<T>observable,Pagepage)
20+
{
21+
varunloaded=page.Events().Unloaded;
22+
returnobservable.TakeUntil(unloaded);
23+
}
24+
}
25+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
Ce fichier contient des directives runtime, des spécifications relatives aux types auxquels votre application a accès
4+
via la réflexion et d'autres modèles de code dynamique. Les directives runtime permettent de contrôler
5+
l'optimiseur .NET Native et de vérifier qu'il ne supprime pas le code accessible à votre bibliothèque. Si votre
6+
bibliothèque ne fait pas de réflexion, vous n'avez pas à modifier ce fichier en principe. Cependant,
7+
si votre bibliothèque effectue une réflexion des types, en particulier les types qui lui sont passés ou qui dérivent de ses types,
8+
vous devez écrire des directives runtime.
9+
10+
En règle générale, l'usage de la réflexion dans les bibliothèques permet de découvrir les informations relatives aux types passés
11+
à la bibliothèque. Les directives runtime ont trois façons d'exprimer les exigences des types passés à
12+
votre bibliothèque.
13+
14+
1. Parameter, GenericParameter, TypeParameter, TypeEnumerableParameter
15+
Utilisez ces directives pour refléter les types passés en tant que paramètres.
16+
17+
2. SubTypes
18+
Utilisez une directive SubTypes pour refléter les types dérivés d'un autre type.
19+
20+
3. AttributeImplies
21+
Utilisez une directive AttributeImplies pour indiquer que votre bibliothèque doit refléter
22+
les types ou les méthodes décorés avec un attribut.
23+
24+
Pour plus d'informations sur l'écriture de directives runtime pour les bibliothèques, visitez
25+
https://go.microsoft.com/fwlink/?LinkID=391919
26+
-->
27+
<Directivesxmlns="http://schemas.microsoft.com/netfx/2013/01/metadata">
28+
<LibraryName="ReduxSimple.Uwp">
29+
30+
<!-- ajoutez ici les directives pour votre bibliothèque-->
31+
32+
</Library>
33+
</Directives>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<ProjectSdk="MSBuild.Sdk.Extras">
2+
<PropertyGroup>
3+
<TargetFramework>uap10.0.16299</TargetFramework>
4+
<RootNamespace>ReduxSimple.Uwp</RootNamespace>
5+
<PackageId>ReduxSimple.Uwp</PackageId>
6+
<Version>3.4.0-preview001</Version>
7+
<Authors>David Bottiau</Authors>
8+
<Title>ReduxSimple for UWP</Title>
9+
<Description>Simple Stupid Redux Store using Reactive Extensions - Store in UWP applications</Description>
10+
<PackageProjectUrl>https://github.com/Odonno/ReduxSimple</PackageProjectUrl>
11+
<RepositoryUrl>https://github.com/Odonno/ReduxSimple</RepositoryUrl>
12+
<Company />
13+
<PackageIconUrl>https://raw.githubusercontent.com/Odonno/ReduxSimple/master/images/logo.png</PackageIconUrl>
14+
<PackageTags>Redux Reactive ReactiveExtensions Rx ReduxSimple State Management UWP</PackageTags>
15+
16+
<LangVersion>8.0</LangVersion>
17+
<Nullable>enable</Nullable>
18+
</PropertyGroup>
19+
20+
<ItemGroup>
21+
<PackageReferenceInclude="ReactiveUI.Events"Version="11.3.1" />
22+
</ItemGroup>
23+
24+
<ItemGroup>
25+
<ProjectReferenceInclude="..\ReduxSimple\ReduxSimple.csproj" />
26+
</ItemGroup>
27+
</Project>

‎ReduxSimple.sln‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{D666B934
2727
EndProject
2828
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") ="ReduxSimple.Tests.Setup","ReduxSimple.Tests.Setup\ReduxSimple.Tests.Setup.csproj","{1C8FFA2D-649A-4027-B098-72FF1024E68E}"
2929
EndProject
30+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") ="ReduxSimple.Uwp","ReduxSimple.Uwp\ReduxSimple.Uwp.csproj","{981E7664-7703-4F24-93EC-073A913643E0}"
31+
EndProject
3032
Global
3133
GlobalSection(SolutionConfigurationPlatforms) =preSolution
3234
Debug|Any CPU=Debug|Any CPU
@@ -203,6 +205,26 @@ Global
203205
{1C8FFA2D-649A-4027-B098-72FF1024E68E}.Release|x64.Build.0=Release|Any CPU
204206
{1C8FFA2D-649A-4027-B098-72FF1024E68E}.Release|x86.ActiveCfg=Release|Any CPU
205207
{1C8FFA2D-649A-4027-B098-72FF1024E68E}.Release|x86.Build.0=Release|Any CPU
208+
{981E7664-7703-4F24-93EC-073A913643E0}.Debug|Any CPU.ActiveCfg=Debug|Any CPU
209+
{981E7664-7703-4F24-93EC-073A913643E0}.Debug|Any CPU.Build.0=Debug|Any CPU
210+
{981E7664-7703-4F24-93EC-073A913643E0}.Debug|ARM.ActiveCfg=Debug|Any CPU
211+
{981E7664-7703-4F24-93EC-073A913643E0}.Debug|ARM.Build.0=Debug|Any CPU
212+
{981E7664-7703-4F24-93EC-073A913643E0}.Debug|ARM64.ActiveCfg=Debug|Any CPU
213+
{981E7664-7703-4F24-93EC-073A913643E0}.Debug|ARM64.Build.0=Debug|Any CPU
214+
{981E7664-7703-4F24-93EC-073A913643E0}.Debug|x64.ActiveCfg=Debug|Any CPU
215+
{981E7664-7703-4F24-93EC-073A913643E0}.Debug|x64.Build.0=Debug|Any CPU
216+
{981E7664-7703-4F24-93EC-073A913643E0}.Debug|x86.ActiveCfg=Debug|Any CPU
217+
{981E7664-7703-4F24-93EC-073A913643E0}.Debug|x86.Build.0=Debug|Any CPU
218+
{981E7664-7703-4F24-93EC-073A913643E0}.Release|Any CPU.ActiveCfg=Release|Any CPU
219+
{981E7664-7703-4F24-93EC-073A913643E0}.Release|Any CPU.Build.0=Release|Any CPU
220+
{981E7664-7703-4F24-93EC-073A913643E0}.Release|ARM.ActiveCfg=Release|Any CPU
221+
{981E7664-7703-4F24-93EC-073A913643E0}.Release|ARM.Build.0=Release|Any CPU
222+
{981E7664-7703-4F24-93EC-073A913643E0}.Release|ARM64.ActiveCfg=Release|Any CPU
223+
{981E7664-7703-4F24-93EC-073A913643E0}.Release|ARM64.Build.0=Release|Any CPU
224+
{981E7664-7703-4F24-93EC-073A913643E0}.Release|x64.ActiveCfg=Release|Any CPU
225+
{981E7664-7703-4F24-93EC-073A913643E0}.Release|x64.Build.0=Release|Any CPU
226+
{981E7664-7703-4F24-93EC-073A913643E0}.Release|x86.ActiveCfg=Release|Any CPU
227+
{981E7664-7703-4F24-93EC-073A913643E0}.Release|x86.Build.0=Release|Any CPU
206228
EndGlobalSection
207229
GlobalSection(SolutionProperties) =preSolution
208230
HideSolutionNode =FALSE
@@ -216,6 +238,7 @@ Global
216238
{E47299A5-16CB-4984-83D6-F4578606A844} ={9A1EA15F-C25F-443B-BC79-878D143055E9}
217239
{ACF5236F-F32C-4AAA-A06F-53FAE3875D50} ={53F074A7-BF54-4EA9-92E3-1EF0CE34D5CF}
218240
{1C8FFA2D-649A-4027-B098-72FF1024E68E} ={D666B934-5069-49A1-94FD-C35A8CD91166}
241+
{981E7664-7703-4F24-93EC-073A913643E0} ={9A1EA15F-C25F-443B-BC79-878D143055E9}
219242
EndGlobalSection
220243
GlobalSection(ExtensibilityGlobals) =postSolution
221244
SolutionGuid ={C169837F-C4D7-45A5-AEDF-D2109C99946E}

‎global.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"sdk": {
3-
"version":"3.0.102"
3+
"version":"3.1.402"
44
},
55
"msbuild-sdks": {
66
"MSBuild.Sdk.Extras":"2.0.54"

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp