TweedleDumb - Mock (dumb) Twitter client

Overview

TweetleDumb

Mock (dumb) Twitter client

Thought Process

Even though this is a mock client I wanted to approach it with the mindset that the mock components (network/auth) could be swapped out for their 'real' counterparts and the app would essentially 'just work'™. The core components and view models have included tests.

What's not included

There is no persistence layer included however if I was to include one I would approach it in a similar fashion to the other services. A protocol would sit over whatever implementation was chosen (core data/realm etc). For this application I might also pass the persistence layer to the API component. This would allow auto-storing of incoming data then, should the app be offline or simply fail, the stored data would be provided so the application would have a better chance of not being empty.

Architecture

The application takes advantage of a variety of techniques including:

  • Navigation Coordinators: provides decoupled navigation. View controller are more modular when they don't know about each other - navigation technically becomes view model to view model and the UI is a 'dumb' layer on top, only performing assignments and sending actions.
  • MVVM: provides decoupled logic. When we extract the logic from views into view models we are able to easily test the behaviour of each screen. We can put the view model into any state we want and assert on it without actually needing to load the view at all.
  • Dependency Injection: provides explicit references. When we enforce that all dependencies are injected it becomes easy to reason about the dependency graph in our application. It act as documentation and allow us to very quickly recognise when functionality should be refactored into a separate component.
  • Delegate: I chose delegates as a pub/sub system instead of something like Rx simply to be pragmatic, I haven't used Rx heavily since version 2. I have included a simple MulticastDelegate to support multiple observers where required. This system still allows communication between obejcts to be explicit.
  • Result : provides unified success/failure type. The result type is a fantastic choice for async callbacks and far better than either separate success/failure callbacks or a single with 2 optional values. It provides all of the benefits of a single callback, allowing for actions to be performed regardless of result. It also removes the issues with a single callback using 2 optionals by reducing the possible states to only success and failure.
  • TableViewCellRepresentable: This is a responsibility inversion pattern I developed and use frequently to remove almost all table view boilerplate from view controllers. It also allows view controllers to scale to any number of different cell types without any change to the datasource code. Original article
  • KeyPathAccessible: Provides type safe deserialization of dictionary and arrays. This is a lite wrapper that gives meanigful errors when the value cannot be extracted (similar to the recent Codable tools in swift 4)

Service Layer

The application includes a few simple service objects which the view models use to supply the functionality.

  • KeyValueStore: Provides a common interface to key/value data for the app. It can be applied to UserDefaults, the keychain or even a dictionary for testing.
  • Network: Provides access to raw HTTP requests/responses. The protocol sits on top of the underlying network implementation which can be URLSession, something like AFNetwork or in this case MockNetwork. It allows for the implementation to easily be swapped out if required.
  • API: Provides logic on top of Network that adds the domain specific parts of network access. This includes signing requests or handling API specific errors.
  • Authentication: This provides all the components of auth or user 'session's.
    • Authenticator represents an external authenticator (i.e. twitter/facebook).
    • AuthenticationState holds the current Authentication data and is responsible for clearing or persisting it between sessions.
    • AuthenticationController handles bringing all the pieces together. It uses an Authenticator to get an external token, then API to swap that token for Authentication data which is stored in AuthenticationState
You might also like...
Exemplify a LazyVGrid in SwiftUI in a MVVM pattern with Mock Data and images in assets.
Exemplify a LazyVGrid in SwiftUI in a MVVM pattern with Mock Data and images in assets.

SwiftUI-LazyVGrid Exemplify a LazyVGrid in SwiftUI in a MVVM pattern with Mock Data and images in assets. Screenshots Samples IP & Credits All those b

Mock UIImagePickerController for testing camera based UI in simulator
Mock UIImagePickerController for testing camera based UI in simulator

Mock UIImagePickerController to simulate the camera in iOS simulator.

Library to send mock remote notifications to the iOS simulator
Library to send mock remote notifications to the iOS simulator

SimulatorRemoteNotifications SimulatorRemoteNotifications is a library to send mock remote notifications to the iOS simulator. The library extends UIA

A Popover that mock iOS SkinTone Selection Popover.

IMessage SkinTone Popover This is a popover mock the iOS iMessage Skin Tone Selection Menu (Popover) Features Long press to invoeke the popover, and t

NewsApp- - Built A News App With SwiftUI and Mock Data
NewsApp- - Built A News App With SwiftUI and Mock Data

News APP Built A News App With Swift UI and Mock Data Screen Gif

A travel guide app that implements MVVM design pattern, using mock API.
A travel guide app that implements MVVM design pattern, using mock API.

✈️ Travel Guide App 🏖 A travel guide app that implements MVVM design pattern, using mock API. ✨ Features 🔸 Project Features Written in Swift Impleme

A flexible mock server for automated and regression testing of iOS, Android and other apps.
A flexible mock server for automated and regression testing of iOS, Android and other apps.

Note: This document is intended as a quick introduction to Voodoo. As Voodoo has a large number of features, please refer to Voodoo's Github Wiki for

Mastodon and Twitter client for iOS, iPadOS & macOS
Mastodon and Twitter client for iOS, iPadOS & macOS

Note: Mamoot! is under heavy development and is obviously far from complete at this moment. We're currently looking for more people to work with us, s

A collection of Swift tips & tricks that I've shared on Twitter

⚠️ This list is no longer being updated. For my latest Swift tips, checkout the "Tips" section on Swift by Sundell. Swift tips & tricks ⚡️ One of the

Swifter - A Twitter framework for iOS & OS X written in Swift
Swifter - A Twitter framework for iOS & OS X written in Swift

Getting Started Installation If you're using Xcode 6 and above, Swifter can be installed by simply dragging the Swifter Xcode project into your own pr

An image viewer à la Twitter
An image viewer à la Twitter

For the latest changes see the CHANGELOG Install CocoaPods pod 'ImageViewer' Carthage github "Krisiacik/ImageViewer" Sample Usage For a detailed examp

Simple PhotoBrowser/Viewer inspired by facebook, twitter photo browsers written by swift
Simple PhotoBrowser/Viewer inspired by facebook, twitter photo browsers written by swift

SKPhotoBrowser Simple PhotoBrowser/Viewer inspired by facebook, twitter photo browsers written by swift features Display one or more images by providi

A Splash view that animates and reveals its content, inspired by Twitter splash
A Splash view that animates and reveals its content, inspired by Twitter splash

RevealingSplashView A Splash view that animates and reveals its content, inspired by the Twitter splash. ⭐ Features Customizable reveal icon image. Cu

SwiftUI: Components Library Inspired by Twitter's Bootstrap
SwiftUI: Components Library Inspired by Twitter's Bootstrap

bootswiftui SwiftUI: Components Library Inspired by Twitter's Bootstrap Warning This is just SwiftUI exercise. Please do not consider using this repo

📰 iOS news app in the style of the NYT, WSJ, CNN, BBC, FB, Twitter, Reddit & more - Includes a tvOS app :tv:
📰 iOS news app in the style of the NYT, WSJ, CNN, BBC, FB, Twitter, Reddit & more - Includes a tvOS app :tv:

News iOS news app in the style of Apollo, Apple News, Axios, BBC, CNN, Facebook, Facebook News, FastNews, Flipboard, Lil News, NBC News, Reddit, The N

A Safari extension that redirects Twitter, YouTube, Reddit, and more to privacy friendly alternatives.
A Safari extension that redirects Twitter, YouTube, Reddit, and more to privacy friendly alternatives.

Privacy Redirect for Safari A configurable web extension that redirects Twitter, YouTube, Reddit, Google Maps, Google Search, and Google Translate to

Basic app to show how to login with Facebook, Google, Twitter. Created for learning purpose :) using Xcode 9 and Swift 4.0
Basic app to show how to login with Facebook, Google, Twitter. Created for learning purpose :) using Xcode 9 and Swift 4.0

Social Logins iOS Basic app to show how to login with Facebook, Google, Twitter. Created for learning purpose :) using Xcode 9 and Swift 4.0 Note: Bef

Returns true for all possible feature flags within the Twitter Mac app!

twitterinject Returns true for all possible feature flags within the Twitter Mac app! On Apple platforms, the default feature flags are present within

This is a simple mobile app which is connect to the Twitter API
This is a simple mobile app which is connect to the Twitter API

Project 3 - My Twitter My Twitter is a basic twitter app to read your tweets. Time spent on two parts: 8.5 hours spent in total Twitter - Part II This

Comments
  • Complete Tutorial

    Complete Tutorial

    This is a beautiful code, is there a way you could do a complete tutorial on something like this(or point me to anyone available), I actually wish I could have my code structured like this, but I have no idea how don't even know where to begin.

    opened by moderateepheezy 0
Owner
Ian Keen
Ian Keen
A Swift mailing list client for iPhone and iPad

Due to costs and lack of interest, I’ve had to take down the Charter service. If you’re interested in running your own copy, get in touch and I can se

Matthew Palmer 526 Dec 24, 2022
iOS client for newsapi.org

DailyFeed iOS client for NewsAPI.org. Now access latest ?? from Best News Agencies and ?? from around the ?? ?? at your fingertips ?? . Features Daily

Sumit Paul 128 Nov 22, 2022
Twitter-Client - A twitter client that allow users to view tweets on their iphone

Project 3 - Twitter Client Name of your app is a basic twitter app to read your

null 0 Feb 7, 2022
small iOS & ipadOS application written in SwiftUI and Combine, that fetches twitter users and tweets using Twitter's api

HomeTwitter Small iOS & ipadOS application written in SwiftUI and Combine, that fetches twitter users and tweets using Twitter's api. This is just a s

Sorin Miroiu 1 May 13, 2022
Twitter Kit is a native SDK to include Twitter content inside mobile apps.

Twitter will be discontinuing support for Twitter Kit on October 31, 2018. Read the blog post here. Twitter Kit for iOS Background Twitter Kit is a na

Twitter Archive 674 Dec 18, 2022
Twitter Text Libraries. This code is used at Twitter to tokenize and parse text to meet the expectations for what can be used on the platform.

twitter-text This repository is a collection of libraries and conformance tests to standardize parsing of Tweet text. It synchronizes development, tes

Twitter 2.9k Dec 27, 2022
🐦 An asynchronous Twitter library based on the Twitter v2 API

Twift Twift is an asynchronous Swift library for the Twitter v2 API. No external dependencies Only one callback-based method (requestUserCredentials)

Daniel Eden 91 Jan 1, 2023
Mock Alamofire and URLSession requests without touching your code implementation

Mocker is a library written in Swift which makes it possible to mock data requests using a custom URLProtocol. Features Requirements Usage Activating

WeTransfer 898 Dec 26, 2022
MockSwift is a Mock library written in Swift.

Welcome to MockSwift MockSwift allows you to write mocks and make better tests. Because MockSwift is an open source library 100% written in Swift, it

Jordhan Leoture 82 Dec 17, 2022
🐤Dynamically Mock server behaviors and responses in Swift

Kakapo Dynamically Mock server behaviors and responses. Contents Why Kakapo? Features Installation Usage Serializable protocol Router: Register and In

DevLucky 764 Aug 23, 2022