Enrichment - GetStream/stream-swift GitHub Wiki
Collections and Users
let userFeed = Client.shared.flatFeed(feedSlug: "user", userId: "jack")
// setup an enriched activity type with the `Post` as the subclass of `CollectionObject`
typealias UserPostActivity = EnrichedActivity<User, Post, String>
Client.shared.add(collectionObject: Post(text: "...", id: "42-ways-to-improve-your-feed")) { _ in
let post = try! result.get()
userFeed.add(UserPostActivity(actor: User.current!, verb: "post", object: post)) { _ in
// if we now read Jack's feed we will get automatically the enriched data
userFeed.get(typeOf: UserPostActivity.self) { result in
print(result)
// we can also update Jack's post and get the new version
// automatically propagated to his feed and its followers
post.text = "new version of the post"
Client.shared.update(collectionObject: post) { _ in
userFeed.get(typeOf: UserPostActivity.self) { result in
// jack's feed now has the new version of the data
print(result)
}
}
}
}
}