Skip to content

Instantly share code, notes, and snippets.

@Bradysm
Created August 9, 2020 15:23
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 Bradysm/79191807718b252dadc7aae5fd94591f to your computer and use it in GitHub Desktop.
Save Bradysm/79191807718b252dadc7aae5fd94591f to your computer and use it in GitHub Desktop.
final class ChatRoomViewModel: ObservableObject {
/// service used to send message to chat room
private let messagingService: MessageSendable
/// username of current user of application
private(set) var username: String
/// current message typed in view
@Published var typedMessage = ""
/// message to display to user upon error
@Published var errorMessage: String? = nil
/// constructor that injects services used within the view model
init(messagingService: MessageSendable, username: String) {
self.messagingService = messagingService
self.username = username
}
//MARK - intents
//... implementation of intents left out for readability
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment