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

Remove all usages of the internal keyword #10

Merged
merged 1 commit into from
Mar 24, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions Sources/ParseLiveQuery/Client.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@ import SocketRocket
*/
@objc(PFLiveQueryClient)
public class Client: NSObject {
internal let host: NSURL
internal let applicationId: String
internal let clientKey: String?
let host: NSURL
let applicationId: String
let clientKey: String?

internal var socket: SRWebSocket?
internal var disconnected = false
var socket: SRWebSocket?
var disconnected = false

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

internal let queue = dispatch_queue_create("com.parse.livequery", DISPATCH_QUEUE_SERIAL)
let queue = dispatch_queue_create("com.parse.livequery", DISPATCH_QUEUE_SERIAL)

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

internal func unsubscribe(@noescape matching matcher: SubscriptionRecord -> Bool) {
func unsubscribe(@noescape matching matcher: SubscriptionRecord -> Bool) {
subscriptions.filter {
matcher($0)
}.forEach {
Expand Down
6 changes: 3 additions & 3 deletions Sources/ParseLiveQuery/Internal/BoltsHelpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
import Bolts
import BoltsSwift

internal let unknownDomain = "unknown"
let unknownDomain = "unknown"

internal func objcTask<T where T: AnyObject>(task: Task<T>) -> BFTask {
func objcTask<T where T: AnyObject>(task: Task<T>) -> BFTask {
let taskCompletionSource = BFTaskCompletionSource()
task.continueWith { task in
if task.cancelled {
Expand All @@ -27,7 +27,7 @@ internal func objcTask<T where T: AnyObject>(task: Task<T>) -> BFTask {
return taskCompletionSource.task
}

internal func swiftTask(task: BFTask) -> Task<AnyObject> {
func swiftTask(task: BFTask) -> Task<AnyObject> {
let taskCompletionSource = TaskCompletionSource<AnyObject>()
task.continueWithBlock { task in
if task.cancelled {
Expand Down
19 changes: 10 additions & 9 deletions Sources/ParseLiveQuery/Internal/ClientPrivate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ private func parseObject<T: PFObject>(objectDictionary: [String:AnyObject]) thro
}

let parseObject = T(withoutDataWithClassName: parseClassName, objectId: objectId)

objectDictionary.filter { key, _ in
key != "parseClassName" && key != "objectId"
}.forEach { key, value in
Expand All @@ -33,8 +34,8 @@ private func parseObject<T: PFObject>(objectDictionary: [String:AnyObject]) thro
// MARK: Subscriptions
// ---------------

internal extension Client {
internal class SubscriptionRecord {
extension Client {
class SubscriptionRecord {
weak var subscriptionHandler: AnyObject?

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

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

internal init(value: Int) {
init(value: Int) {
self.value = value
}
}
Expand Down Expand Up @@ -155,7 +156,7 @@ extension Client: SRWebSocketDelegate {
// MARK: Operations
// -------------------

internal extension Event {
extension Event {
init(serverResponse: ServerResponse, inout requestId: Client.RequestId) throws {
switch serverResponse {
case .Enter(let reqId, let object):
Expand Down Expand Up @@ -183,7 +184,7 @@ internal extension Event {
}
}

internal extension Client {
extension Client {
private func subscriptionRecord(requestId: RequestId) -> SubscriptionRecord? {
guard
let recordIndex = self.subscriptions.indexOf({ $0.requestId == requestId }),
Expand All @@ -195,7 +196,7 @@ internal extension Client {
return record
}

internal func sendOperationAsync(operation: ClientOperation) -> Task<Void> {
func sendOperationAsync(operation: ClientOperation) -> Task<Void> {
return Task(.Queue(queue)) {
let jsonEncoded = operation.JSONObjectRepresentation
let jsonData = try NSJSONSerialization.dataWithJSONObject(jsonEncoded, options: NSJSONWritingOptions(rawValue: 0))
Expand All @@ -205,7 +206,7 @@ internal extension Client {
}
}

internal func handleOperationAsync(string: String) -> Task<Void> {
func handleOperationAsync(string: String) -> Task<Void> {
return Task(.Queue(queue)) {
guard
let jsonData = string.dataUsingEncoding(NSUTF8StringEncoding),
Expand Down
6 changes: 3 additions & 3 deletions Sources/ParseLiveQuery/Internal/Operation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import Foundation
import Parse

internal enum ClientOperation {
enum ClientOperation {
case Connect(applicationId: String, sessionToken: String)
case Subscribe(requestId: Client.RequestId, query: PFQuery)
case Unsubscribe(requestId: Client.RequestId)
Expand All @@ -29,7 +29,7 @@ internal enum ClientOperation {
}
}

internal enum ServerResponse {
enum ServerResponse {
case Redirect(url: String)
case Connected()

Expand All @@ -44,7 +44,7 @@ internal enum ServerResponse {

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

internal init(json: [String : AnyObject]) throws {
init(json: [String : AnyObject]) throws {
func jsonValue<T>(json: [String:AnyObject], _ key: String) throws -> T {
guard let value = json[key] as? T
else {
Expand Down
4 changes: 2 additions & 2 deletions Sources/ParseLiveQuery/Internal/QueryEncoder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import Parse
/**
NOTE: This is super hacky, and we need a better answer for this.
*/
internal extension Dictionary where Key: StringLiteralConvertible, Value: AnyObject {
internal init(query: PFQuery) {
extension Dictionary where Key: StringLiteralConvertible, Value: AnyObject {
init(query: PFQuery) {
self.init()

let queryState = query.valueForKey("state")
Expand Down
8 changes: 4 additions & 4 deletions Sources/ParseLiveQuery/ObjCCompat.swift
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,10 @@ public struct ObjCCompat {
public typealias EventHandler = @convention(block) (PFQuery, Event) -> Void
public typealias ObjectHandler = @convention(block) (PFQuery, PFObject) -> Void

internal var subscribeHandlers = [SubscribeHandler]()
internal var unsubscribeHandlers = [SubscribeHandler]()
internal var errorHandlers = [ErrorHandler]()
internal var eventHandlers = [EventHandler]()
var subscribeHandlers = [SubscribeHandler]()
var unsubscribeHandlers = [SubscribeHandler]()
var errorHandlers = [ErrorHandler]()
var eventHandlers = [EventHandler]()

/**
Register a callback for when a client succesfully subscribes to a query.
Expand Down
2 changes: 1 addition & 1 deletion Sources/ParseLiveQuery/Subscription.swift
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public enum Event<T where T: PFObject> {
/// The object has been deleted, and is no longer included in the query
case Deleted(T)

internal init<V where V: PFObject>(event: Event<V>) {
init<V where V: PFObject>(event: Event<V>) {
switch event {
case .Entered(let value as T): self = .Entered(value)
case .Left(let value as T): self = .Left(value)
Expand Down