Skip to content

Commit

Permalink
Migrate some WP8 fixups to WinRT
Browse files Browse the repository at this point in the history
  • Loading branch information
anaisbetts committed Feb 11, 2013
1 parent 5469611 commit f9c1da0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
1 change: 1 addition & 0 deletions MobileSample-WP8/ViewModels/TestPage1ViewModel.cs
Expand Up @@ -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; }
Expand Down
3 changes: 2 additions & 1 deletion ReactiveUI.Mobile/PhoneServiceStateDriver.cs
Expand Up @@ -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);
Expand Down
15 changes: 8 additions & 7 deletions ReactiveUI.Mobile/WinRTAutoSuspendApplication.cs
Expand Up @@ -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();
Expand Down Expand Up @@ -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>();
Expand All @@ -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);
}
}
Expand Down

0 comments on commit f9c1da0

Please sign in to comment.