public async Task <ReadModel <TState> > ReadFrom(TId id) { var streamData = await reader.ReadFrom(id.ToString()); var events = await streamData.Events.Reverse().Select(x => x.ToItemWithType()).ToArrayAsync(); var rehydratedState = configs.StateRehydrator.RehydrateFrom <TState>(events); //TODO: REPLACE WHEN BO CHANGES TO LONG!! return(new ReadModel <TState>(rehydratedState, (int)streamData.StoredEventPosition.ToInt64())); }
public async Task Initialize(Func <IAmAStoredEvent, bool> loadEventPredicate = null) { CheckDisposedState(); //TODO: user credentials var data = await eventReader.ReadFrom(streamName, loadEventPredicate); streamExists = data.StreamExists; var events = await data.Events.Reverse().ToArrayAsync(); LoadFromEvents(events.Select(x => x.ToItemWithType()).ToArray(), data.StoredEventPosition.ToInt64()); }