Skip to content

Instantly share code, notes, and snippets.

@ionoy
Created June 14, 2016 17:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ionoy/c04aa730f605c3a74b2062f838196214 to your computer and use it in GitHub Desktop.
Save ionoy/c04aa730f605c3a74b2062f838196214 to your computer and use it in GitHub Desktop.
namespace Nitra.Visualizer.ViewModels
{
public class AstNodeViewModel : ReactiveObject
{
readonly ObjectDescriptor _objectDescriptor;
readonly NitraClient _client;
[Reactive]
public bool NeedLoadContent { get; private set; }
public ReactiveList<AstNodeViewModel> Items { get; set; }
public IReactiveCommand<IList<AstNodeViewModel>> LoadItems { get; }
public AstNodeViewModel(NitraClient client, ObjectDescriptor objectDescriptor)
{
_client = client;
_objectDescriptor = objectDescriptor;
Items = new ReactiveList<AstNodeViewModel>();
if (objectDescriptor.IsObject || objectDescriptor.IsSeq && objectDescriptor.Count > 0)
{
NeedLoadContent = true;
Items.Add(null);
}
LoadItems = ReactiveCommand.CreateAsyncTask(_ => client.ReceiveItemsAsync());
LoadItems.Subscribe(loaded => Items.AddRange(loaded));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment