This file contains hidden or 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
| 04132fa5fe0845de08d684d9494820bfb74f671b3a748425acf8b345239a681fe0807fba537585181c2d6049c58fcb8c3a5f58162db16dfde0c1f146649178ba7b |
This file contains hidden or 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
| //1) Notification center-specific implementation of UpdateObserving | |
| class NotificationObserver: UpdateObserving { | |
| var observer: NSObjectProtocol? | |
| init(notificationObserver: NSObjectProtocol?) { | |
| self.observer = notificationObserver | |
| } | |
This file contains hidden or 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
| //1) Have a protocol that serves as a placeholder for something that is observing updates- mainly so you can unsubscribe from updates later when you no longer need them | |
| protocol UpdateObserving { | |
| func unsubscribe() | |
| } | |
| //1a) Implement that protocol for Firebase. It needs a ref that can unsubscribe and a handle to the specific subscription |
This file contains hidden or 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
| import Foundation | |
| typealias ReturnCompletionBlock<T> = (T?) -> () | |
| //yes, this is a closure with a closure as a parameter | |
| typealias AsyncListElementFunction<T> = (ReturnCompletionBlock<T>) -> () | |
| class AsyncListBuilder<T> { | |
| var elementFunctions = [AsyncListElementFunction<T>]() |
This file contains hidden or 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
| func posts(forTag tagKey: String, completionBlock: (([Post]) -> ()) { | |
| let userId = FIRAuth.auth().currentUser?.uid | |
| let ref = FIRDatabase.database().reference() | |
| let dispatchGroup = DispatchGroup() | |
| var posts = [Post]() //I can put all the posts here as I retrieve them | |
| ref.child("users").child(userId!).child("tags").child(tagKey).observeSingleEvent(of: .value, with: {(tagSnapshot) in | |
| let tag = Tag(fromSnapshot: tagSnapshot) |
This file contains hidden or 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
| { | |
| "users" : { | |
| "user1" : { | |
| "posts" : { | |
| "post1" : { | |
| "title" : "blah", | |
| "body" : "more blah", | |
| "tags" : {"boring" : true, "lame" : true} | |
| }, | |
| "post2" : { |
This file contains hidden or 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
| class CalendarPicker extends React.Component { | |
| constructor() { | |
| var randomId = CustomFramework.guid(); //get a GUID from the framework that will be the ID for the legacy calendar control | |
| this.state = {controlId: randomId, value: null}; //we'll set value later based on legacy control events (see below) | |
| } | |
| render() { | |
| //On initial render, put an empty div with a unique ID on the DOM. | |
| //The control will be inserted inside this container. |
This file contains hidden or 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
| public class SomeContainerOfThings | |
| { | |
| List<IThing> Things {get;set;} | |
| //old - performed at O(N^2) | |
| IEnumerable<IThing> GetThingsAlsoIn(SomeContainerOfThings other) | |
| { | |
| return this.Things.Where(thisThing => other.Things.Any(otherThing => thisThing.Name == otherThing.Name)); | |
| } | |
This file contains hidden or 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
| // AppDelegate.swift -------------------------------------------------------------------------------------------- | |
| //Add this stuff to AppDelegate (in addition to whatever is already in there) to enable Firebase and the auth-specific URL handlers | |
| class AppDelegate: UIResponder, UIApplicationDelegate { | |
| var window: UIWindow? | |
| func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { | |
| //setup firebase |