# Async / await with ParseSwift Query sample?

**URL:** <https://community.parseplatform.org/t/async-await-with-parseswift-query-sample/2099>\
**Category:** ParseSwift SDK\
**Created:** [October 18, 2021, 5:59pm UTC](https://community.parseplatform.org/t/async-await-with-parseswift-query-sample/2099 "2021-10-18T17:59:25Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![cbaker6](https://community.parseplatform.org/user_avatar/community.parseplatform.org/cbaker6/32/114_2.png) [@cbaker6](https://community.parseplatform.org/u/cbaker6)\
**Post date:** [October 18, 2021, 10:43pm UTC](https://community.parseplatform.org/t/async-await-with-parseswift-query-sample/2099/2 "2021-10-18T22:43:57Z")

</div>

A sample repo I created, [SnapCat](https://github.com/netreconlab/SnapCat), shows off a lot of the Parse Swift SDK capabilities such as: SwiftUI compatibility (Models & ViewModels), LiveQuery, async/await, etc.

For comparison, you can look at the `iOS14` branch which only uses completion handlers. A fetch example is below (query and everything else is very similar):

> <https://github.com/netreconlab/SnapCat/blob/8218047ef311c7610da8f4cde6db0dd1108c0047/SnapCat/Utility.swift#L29-L42>

The same code written using async/await is below:

> <https://github.com/netreconlab/SnapCat/blob/2490ec4026d2bef89e79adc45ee9d1d41ccf99fc/SnapCat/Utility.swift#L28-L39>

There are tons of examples how to use the SDK with MVVM and SwiftUI. To highlight a one I think is super useful, is creating custom view models that automatically subscribe to live queries along with fetch on first call. This allows you to make dynamic timelines that automatically reflect updates in a social media app. The custom view model to do this is below:

> <https://github.com/netreconlab/SnapCat/blob/main/SnapCat/CustomViewModels/QueryImageViewModel.swift>

Then you use it to create a timeline view like this:

> <https://github.com/netreconlab/SnapCat/blob/7e9ce52968b940b7e7cff6c9c3b064383f09a09d/SnapCat/Home/TimeLineView.swift>

Basically, any new posts from people you follow, new comments or likes, automatically are reflected on the timeline without having to refresh.

---

_[View the full topic](https://community.parseplatform.org/t/async-await-with-parseswift-query-sample/2099)._
