-
-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: improve layouts of live query subscription files (#273)
* WIP * improve live query subscription files * add more publisher docs * lint
- Loading branch information
Showing
8 changed files
with
115 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ coverage: | |
status: | ||
patch: | ||
default: | ||
target: auto | ||
target: 36 | ||
changes: false | ||
project: | ||
default: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// | ||
// LiveQueryConstants.swift | ||
// ParseSwift | ||
// | ||
// Created by Corey Baker on 11/3/21. | ||
// Copyright © 2021 Parse Community. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
/** | ||
Represents an update on a specific object from the `ParseLiveQuery` Server. | ||
- Entered: The object has been updated, and is now included in the query. | ||
- Left: The object has been updated, and is no longer included in the query. | ||
- Created: The object has been created, and is a part of the query. | ||
- Updated: The object has been updated, and is still a part of the query. | ||
- Deleted: The object has been deleted, and is no longer included in the query. | ||
*/ | ||
public enum Event<T: ParseObject> { | ||
/// The object has been updated, and is now included in the query. | ||
case entered(T) | ||
|
||
/// The object has been updated, and is no longer included in the query. | ||
case left(T) | ||
|
||
/// The object has been created, and is a part of the query. | ||
case created(T) | ||
|
||
/// The object has been updated, and is still a part of the query. | ||
case updated(T) | ||
|
||
/// The object has been deleted, and is no longer included in the query. | ||
case deleted(T) | ||
|
||
init?(event: EventResponse<T>) { | ||
switch event.op { | ||
case .enter: self = .entered(event.object) | ||
case .leave: self = .left(event.object) | ||
case .create: self = .created(event.object) | ||
case .update: self = .updated(event.object) | ||
case .delete: self = .deleted(event.object) | ||
default: fatalError() | ||
} | ||
} | ||
} | ||
|
||
internal func == <T>(lhs: Event<T>, rhs: Event<T>) -> Bool { | ||
switch (lhs, rhs) { | ||
case (.entered(let obj1), .entered(let obj2)): return obj1 == obj2 | ||
case (.left(let obj1), .left(let obj2)): return obj1 == obj2 | ||
case (.created(let obj1), .created(let obj2)): return obj1 == obj2 | ||
case (.updated(let obj1), .updated(let obj2)): return obj1 == obj2 | ||
case (.deleted(let obj1), .deleted(let obj2)): return obj1 == obj2 | ||
default: return false | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters