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 StoreViewController: UIViewController { | |
| typealias Factory = BooksViewControllerBuilder | |
| private let factory: Factory | |
| init(_ factory: Factory) { | |
| self.factory = factory | |
| super.init(nibName: nil, bundle: nil) | |
| } | |
| required init?(coder aDecoder: NSCoder) { fatalError("init(coder:) has not been implemented") } |
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 StoreViewController: UIViewController { | |
| typealias Factory = BooksViewControllerBuilder & VideosViewControllerBuilder | |
| private let factory: Factory | |
| init(_ factory: Factory) { | |
| self.factory = factory | |
| super.init(nibName: nil, bundle: nil) | |
| } | |
| required init?(coder aDecoder: NSCoder) { fatalError("init(coder:) has not been implemented") } |
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 VideosViewController: UIViewController { | |
| } | |
| protocol VideosViewControllerBuilder { | |
| func build() -> VideosViewController | |
| } | |
| extension DependencyContaier: VideosViewControllerBuilder { | |
| func build() -> VideosViewController { |
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
| struct Book { | |
| let id: String | |
| let name: String | |
| let author: String | |
| } | |
| typealias Books = [Book] |
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
| protocol BooksViewControllerBuilder { | |
| func build() -> BooksViewContoller | |
| } | |
| extension DependecyContainer: BooksViewControllerBuilder { | |
| func build() -> BooksViewContoller { | |
| return BooksViewContoller(bookService: bookService, auth: auth) | |
| } | |
| } |
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
| struct DependecyContainer { | |
| private let bookService: BookService | |
| private let auth: Auth | |
| init(bookService: BookService = MockBookService(), | |
| auth: Auth = MockAuth()) { | |
| self.bookService = bookService | |
| self.auth = auth | |
| } | |
| } |
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 MockBookService: BookService { | |
| func fetchPopularBooks(then handler: (Books) -> Void) { | |
| let books = [ | |
| Book(id: "1", name: "X", author: "X"), | |
| Book(id: "2", name: "Y", author: "Y"), | |
| Book(id: "3", name: "Z", author: "Z") | |
| ] | |
| handler(books) | |
| } |
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
| protocol BookService { | |
| typealias Handler = (Books) -> Void | |
| // Global popular books (Anonymous) | |
| func fetchPopularBooks(then handler: Handler) | |
| // Special books based on logged in user preferences | |
| func fetchRelatedBooks(then handler: Handler) | |
| } |
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
| # Move commit from one branch to another. | |
| git checkout dev | |
| git cherry-pick 12345 | |
| git checkout master | |
| git reset 12345 | |
| # Git reset |
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
| function removeByCategory(category){ | |
| let allLinks = document.getElementsByTagName('a') | |
| let links = [] | |
| for(let i = 0; i<allLinks.length; i++){ | |
| if(allLinks[i].text === category){ | |
| links.push(allLinks[i]) | |
| } | |
| } |
NewerOlder