Permalink
Browse files

Migrate some WP8 fixups to WinRT

  • Loading branch information...
1 parent 5469611 commit f9c1da07f2c7c33ab957df69ffd11121ceb7a9c7 @paulcbetts paulcbetts committed Feb 11, 2013
@@ -11,6 +11,7 @@ public class TestPage1ViewModel : ReactiveObject, IRoutableViewModel
public string UrlPathSegment { get { return "test1"; } }
public IScreen HostScreen { get; private set; }
+ [DataMember]
Guid _RandomGuid;
public Guid RandomGuid {
get { return _RandomGuid; }
@@ -25,7 +25,8 @@ public PhoneServiceStateDriver(JsonSerializerSettings settings)
{
var serializer = JsonSerializer.Create(SerializerSettings);
try {
- var reader = new JsonTextReader(new StringReader((string)PhoneApplicationService.Current.State["state"]));
+ var state = (string) PhoneApplicationService.Current.State["state"];
+ var reader = new JsonTextReader(new StringReader(state));
return Observable.Return(serializer.Deserialize<T>(reader));
} catch (Exception ex) {
return Observable.Throw<T>(ex);
@@ -37,9 +37,15 @@ public abstract class AutoSuspendApplication : Application, IEnableLogger
public IApplicationRootState ViewModel {
get { return _ViewModel; }
- set { _ViewModel = value; _viewModelChanged.OnNext(value); }
+ set {
+ if (_ViewModel == value) return;
+ _ViewModel = value;
+ _viewModelChanged.OnNext(value);
+ }
}
+
+
protected AutoSuspendApplication()
{
var host = new SuspensionHost();
@@ -111,9 +117,7 @@ internal void setupDefaultSuspendResume(ISuspensionDriver driver)
Observable.Defer(() => Observable.Return(RxApp.GetService<IApplicationRootState>())),
"Failed to restore app state from storage, creating from scratch")
.ObserveOn(RxApp.DeferredScheduler)
- .Subscribe(x => {
- ViewModel = x;
- });
+ .Subscribe(x => ViewModel = x);
SuspensionHost.IsLaunchingNew.Subscribe(_ => {
ViewModel = RxApp.GetService<IApplicationRootState>();
@@ -123,9 +127,6 @@ internal void setupDefaultSuspendResume(ISuspensionDriver driver)
protected override void OnLaunched(LaunchActivatedEventArgs args)
{
base.OnLaunched(args);
-
- // NB: We can't touch RxApp until OnLaunched is called :-/
- RxApp.Register(typeof(WinRTSuspensionHost), typeof(ISuspensionHost));
_launched.OnNext(args);
}
}

0 comments on commit f9c1da0

Please sign in to comment.