Skip to content
This repository was archived by the owner on Jun 13, 2023. It is now read-only.

Commit 27ec03a

Browse files
Remove all usages of the internal keyword
This is mostly redundant and can hurt readability for people new to swift.
1 parent 4531b82 commit 27ec03a

File tree

8 files changed

+33
-32
lines changed

8 files changed

+33
-32
lines changed

Sources/ParseLiveQuery/Client.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,19 @@ import SocketRocket
1818
*/
1919
@objc(PFLiveQueryClient)
2020
public class Client: NSObject {
21-
internal let host: NSURL
22-
internal let applicationId: String
23-
internal let clientKey: String?
21+
let host: NSURL
22+
let applicationId: String
23+
let clientKey: String?
2424

25-
internal var socket: SRWebSocket?
26-
internal var disconnected = false
25+
var socket: SRWebSocket?
26+
var disconnected = false
2727

2828
// This allows us to easily plug in another request ID generation scheme, or more easily change the request id type
2929
// if needed (technically this could be a string).
30-
internal let requestIdGenerator: () -> RequestId
31-
internal var subscriptions = [SubscriptionRecord]()
30+
let requestIdGenerator: () -> RequestId
31+
var subscriptions = [SubscriptionRecord]()
3232

33-
internal let queue = dispatch_queue_create("com.parse.livequery", DISPATCH_QUEUE_SERIAL)
33+
let queue = dispatch_queue_create("com.parse.livequery", DISPATCH_QUEUE_SERIAL)
3434

3535
/**
3636
Creates a Client which automatically attempts to connect to the custom parse-server URL set in Parse.currentConfiguration().
@@ -180,7 +180,7 @@ extension Client {
180180
unsubscribe { $0.query == query && $0.subscriptionHandler === handler }
181181
}
182182

183-
internal func unsubscribe(@noescape matching matcher: SubscriptionRecord -> Bool) {
183+
func unsubscribe(@noescape matching matcher: SubscriptionRecord -> Bool) {
184184
subscriptions.filter {
185185
matcher($0)
186186
}.forEach {

Sources/ParseLiveQuery/Internal/BoltsHelpers.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
import Bolts
1111
import BoltsSwift
1212

13-
internal let unknownDomain = "unknown"
13+
let unknownDomain = "unknown"
1414

15-
internal func objcTask<T where T: AnyObject>(task: Task<T>) -> BFTask {
15+
func objcTask<T where T: AnyObject>(task: Task<T>) -> BFTask {
1616
let taskCompletionSource = BFTaskCompletionSource()
1717
task.continueWith { task in
1818
if task.cancelled {
@@ -27,7 +27,7 @@ internal func objcTask<T where T: AnyObject>(task: Task<T>) -> BFTask {
2727
return taskCompletionSource.task
2828
}
2929

30-
internal func swiftTask(task: BFTask) -> Task<AnyObject> {
30+
func swiftTask(task: BFTask) -> Task<AnyObject> {
3131
let taskCompletionSource = TaskCompletionSource<AnyObject>()
3232
task.continueWithBlock { task in
3333
if task.cancelled {

Sources/ParseLiveQuery/Internal/ClientPrivate.swift

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ private func parseObject<T: PFObject>(objectDictionary: [String:AnyObject]) thro
2121
}
2222

2323
let parseObject = T(withoutDataWithClassName: parseClassName, objectId: objectId)
24+
2425
objectDictionary.filter { key, _ in
2526
key != "parseClassName" && key != "objectId"
2627
}.forEach { key, value in
@@ -33,8 +34,8 @@ private func parseObject<T: PFObject>(objectDictionary: [String:AnyObject]) thro
3334
// MARK: Subscriptions
3435
// ---------------
3536

36-
internal extension Client {
37-
internal class SubscriptionRecord {
37+
extension Client {
38+
class SubscriptionRecord {
3839
weak var subscriptionHandler: AnyObject?
3940

4041
// HandlerClosure captures the generic type info passed into the constructor of SubscriptionRecord,
@@ -99,10 +100,10 @@ internal extension Client {
99100

100101
// An opaque placeholder structed used to ensure that we type-safely create request IDs and don't shoot ourself in
101102
// the foot with array indexes.
102-
internal struct RequestId: Equatable {
103-
internal let value: Int
103+
struct RequestId: Equatable {
104+
let value: Int
104105

105-
internal init(value: Int) {
106+
init(value: Int) {
106107
self.value = value
107108
}
108109
}
@@ -155,7 +156,7 @@ extension Client: SRWebSocketDelegate {
155156
// MARK: Operations
156157
// -------------------
157158

158-
internal extension Event {
159+
extension Event {
159160
init(serverResponse: ServerResponse, inout requestId: Client.RequestId) throws {
160161
switch serverResponse {
161162
case .Enter(let reqId, let object):
@@ -183,7 +184,7 @@ internal extension Event {
183184
}
184185
}
185186

186-
internal extension Client {
187+
extension Client {
187188
private func subscriptionRecord(requestId: RequestId) -> SubscriptionRecord? {
188189
guard
189190
let recordIndex = self.subscriptions.indexOf({ $0.requestId == requestId }),
@@ -195,7 +196,7 @@ internal extension Client {
195196
return record
196197
}
197198

198-
internal func sendOperationAsync(operation: ClientOperation) -> Task<Void> {
199+
func sendOperationAsync(operation: ClientOperation) -> Task<Void> {
199200
return Task(.Queue(queue)) {
200201
let jsonEncoded = operation.JSONObjectRepresentation
201202
let jsonData = try NSJSONSerialization.dataWithJSONObject(jsonEncoded, options: NSJSONWritingOptions(rawValue: 0))
@@ -205,7 +206,7 @@ internal extension Client {
205206
}
206207
}
207208

208-
internal func handleOperationAsync(string: String) -> Task<Void> {
209+
func handleOperationAsync(string: String) -> Task<Void> {
209210
return Task(.Queue(queue)) {
210211
guard
211212
let jsonData = string.dataUsingEncoding(NSUTF8StringEncoding),

Sources/ParseLiveQuery/Internal/Errors.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public struct LiveQueryErrors {
3838
}
3939

4040
/**
41-
An error that is reported when the live query server encounters an internal error.
41+
An error that is reported when the live query server encounters an error.
4242
*/
4343
public struct ServerReportedError: ErrorType {
4444
/// Error code reported by the server.

Sources/ParseLiveQuery/Internal/Operation.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import Foundation
1111
import Parse
1212

13-
internal enum ClientOperation {
13+
enum ClientOperation {
1414
case Connect(applicationId: String, sessionToken: String)
1515
case Subscribe(requestId: Client.RequestId, query: PFQuery)
1616
case Unsubscribe(requestId: Client.RequestId)
@@ -29,7 +29,7 @@ internal enum ClientOperation {
2929
}
3030
}
3131

32-
internal enum ServerResponse {
32+
enum ServerResponse {
3333
case Redirect(url: String)
3434
case Connected()
3535

@@ -44,7 +44,7 @@ internal enum ServerResponse {
4444

4545
case Error(requestId: Client.RequestId?, code: Int, error: String, reconnect: Bool)
4646

47-
internal init(json: [String : AnyObject]) throws {
47+
init(json: [String : AnyObject]) throws {
4848
func jsonValue<T>(json: [String:AnyObject], _ key: String) throws -> T {
4949
guard let value = json[key] as? T
5050
else {

Sources/ParseLiveQuery/Internal/QueryEncoder.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ import Parse
1313
/**
1414
NOTE: This is super hacky, and we need a better answer for this.
1515
*/
16-
internal extension Dictionary where Key: StringLiteralConvertible, Value: AnyObject {
17-
internal init(query: PFQuery) {
16+
extension Dictionary where Key: StringLiteralConvertible, Value: AnyObject {
17+
init(query: PFQuery) {
1818
self.init()
1919

2020
let queryState = query.valueForKey("state")

Sources/ParseLiveQuery/ObjCCompat.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,10 @@ public struct ObjCCompat {
122122
public typealias EventHandler = @convention(block) (PFQuery, Event) -> Void
123123
public typealias ObjectHandler = @convention(block) (PFQuery, PFObject) -> Void
124124

125-
internal var subscribeHandlers = [SubscribeHandler]()
126-
internal var unsubscribeHandlers = [SubscribeHandler]()
127-
internal var errorHandlers = [ErrorHandler]()
128-
internal var eventHandlers = [EventHandler]()
125+
var subscribeHandlers = [SubscribeHandler]()
126+
var unsubscribeHandlers = [SubscribeHandler]()
127+
var errorHandlers = [ErrorHandler]()
128+
var eventHandlers = [EventHandler]()
129129

130130
/**
131131
Register a callback for when a client succesfully subscribes to a query.

Sources/ParseLiveQuery/Subscription.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public enum Event<T where T: PFObject> {
8484
/// The object has been deleted, and is no longer included in the query
8585
case Deleted(T)
8686

87-
internal init<V where V: PFObject>(event: Event<V>) {
87+
init<V where V: PFObject>(event: Event<V>) {
8888
switch event {
8989
case .Entered(let value as T): self = .Entered(value)
9090
case .Left(let value as T): self = .Left(value)

0 commit comments

Comments
 (0)