Simple iOS app in Swift to show AQI for some cities using websocket using Combine + MVVM

Related tags

Networking AQI
Overview

AQI

Simple iOS app in Swift to show AQI for some cities using websocket using Combine + MVVM

This app follows MVVM This app uses combine framework The app supports iOS 13.0+ for all iOS mobile devices

Consists of two pages:

AQI Table View Page

  • Fectches AQI information from web socket
  • Loads this information on table view
  • When fresh data is received from the socket its mapped to the existing data i.e. if new data contains existing city it updates the city modal else new object is created for the city if the new data misses any city we have received earlier then we keep that previous entry
  • When AQI crosses some threshold then tableview cell show some animation to grab attension

View: AQIViewController creates an object to AQIViewModal (aqiViewModal) AQIViewcontroller creates a property which is used to load data on views (info) AQICell is the customised table view cell to show the records AQICell informs AQIViewModal if AQI of city moves to different category

Modal: AqiInfo contains all relevant information required to show the table view Uses enum AQICategory to assign category and uses its computed propety to generate relevant colors Follows Codable protocol

ViewModal: Asks DataManager to download data every 5 seconds Receives data using completion block Modifies received data to get impactful data for views Uses combine to forward this data to AQIViewController and asks it to refresh UI


City AQI View Page

  • Tapping on any cell on the previous page pushes this one
  • Fetches data in cycle of 30 seconds to create AQI barchart using XYCharts

View: CityAQIController creates an object to CityViewModal (cityViewModal) CityAQIController creates a property which is used to load data on views (info) It shows the name of the selected city on the title AQIChart creates bar chart to monitor AQI of city over a duration

Modal: CityAQI contains all relevant information required to show the bar graph for a city over a time Uses enum AQICategory to assign category and uses its computed propety to generate relevant colors Follows Codable protocol

ViewModal: Asks DataManager to download data every 30 seconds Receives data using completion block Identifies selected city aqi object from the received data and add it to existing array Uses combine to forward this array to CityAQIController and asks it to refresh UI


Helper -- DataManager Uses generic object complying to Decodable protocol to return data for websocket Takes dispatchInterval as input paarmeter and listens to connetion to update data

1 2 3

You might also like...
Enable WebSocket in OPC DA/AE Server with JSON return, first time ever
Enable WebSocket in OPC DA/AE Server with JSON return, first time ever

WebSocket4OPC Enable WebSocket in OPC DA/AE Server with JSON return, first time ever DCOM was developed more than 2 decades ago, wich was the pillar o

MultiPeer-Progress-iOS - Swift project to demo the use of the MultiPeer framework to send files between iOS devices and show the progress StatusBarOverlay will automatically show a
StatusBarOverlay will automatically show a "No Internet Connection" bar when your app loses connection, and hide it again. It supports apps which hide the status bar and The Notch

StatusBarOverlay StatusBarOverlay will automatically show a "No Internet Connection" bar when your app loses connection, and hide it again. It support

 Postie - The Next-Level HTTP API Client using Combine
Postie - The Next-Level HTTP API Client using Combine

Postie - The Next-Level HTTP API Client using Combine Postie is a pure Swift library for building URLRequests using property wrappers.

Swift-flows - Simplistic hot and cold flow-based reactive observer pattern for Swift… ideal for MVVM architectures

SwiftFlows Simplistic hot and cold flow-based reactive observer pattern for Swif

GitHub iOS client in RxSwift and MVVM-C clean architecture
GitHub iOS client in RxSwift and MVVM-C clean architecture

GitHub iOS client in RxSwift and MVVM-C clean architecture. FlutterHub - Flutter version available at an early stage KotlinHub - Android version is co

Async network layer with Combine
Async network layer with Combine

Version 1.0.10 Currently Available Platform Version iOS 12.0 tvOS 10.0 macOS 10.15 watchOS 3.0 macCatalyst 13.0 Hover is a Network layer which uses Ap

A Combine-style wrapper around Network's NWConnection with a UDP protocol

A Combine-style wrapper around Network's NWConnection with a UDP protocol

 RxSwift+MVVM 4시간에 끝내기
RxSwift+MVVM 4시간에 끝내기

RxSwift+MVVM 4시간에 끝내기 RxSwift 4시간에 끝내기 (시즌2) Preface 요즘 관심이 높은 RxSwift! RxSwift는

Owner
Amey Vikkram Tiwari
iOS Developer
Amey Vikkram Tiwari
This app is using web-socket for realtime updation of aqi for dedicated inidan cities.

CityWiseAQI This app is using web-socket for realtime updation of aqi for dedicated inidan cities. We're following MVVM architecture in this app. This

Vipul Kumar 2 Feb 7, 2022
Alamofire Network Layer written in swift 5 using the protocol oriented, combine, UIKit, MVVM.

CoreAPI-iOS This project Contains Alamofire Network layer Based on Protocol Oriented Concept and Combine Framework. It is created with UIKit, Alamofir

Mehran Kamalifard 27 Nov 11, 2022
WebSocket(RFC-6455) library written using Swift

DNWebSocket Object-Oriented, Swift-style WebSocket Library (RFC 6455) for Swift-compatible Platforms. Tests Installation Requirements Usage Tests Conf

Gleb Radchenko 36 Jan 29, 2022
A slim implementation of a websocket server using Swift and Vapor 4.0.

Swift Websocket Server Example using Vapor 4.0 This project includes a minimum working example for a websocket server written in Swift. To interact wi

Adrian Hupka 5 Sep 22, 2022
iOS 15, MVVM, Async Await, Core Data, Abstract Network Layer, Repository & DAO design patterns, SwiftUI and Combine

iOS 15, MVVM, Async Await, Core Data, Abstract Network Layer, Repository & DAO design patterns, SwiftUI and Combine

Conrado Mateu Gisbert 18 Dec 23, 2022
Conforming WebSocket (RFC 6455) client library for iOS and Mac OSX

SwiftWebSocket Conforming WebSocket (RFC 6455) client library for iOS and Mac OS

null 0 Dec 24, 2021
OBSwiftSocket is a Swift library to be used for communication with OBS Studio via obs-websocket (v5).

OBSwiftSocket OBSwiftSocket is a Swift library to be used for communication with OBS Studio via obs-websocket (v5). obs-websocket v5 specification: ht

Edon 3 Sep 28, 2022
WebSocket implementation for use by Client and Server

WebSocket ⚠️ This module contains no networking. To create a WebSocket Server, see WebSocketServer. To create a WebSocket Client, see WebSocketClient.

Zewo Graveyard 63 Jan 29, 2022
A conforming Objective-C WebSocket client library.

SocketRocket A conforming WebSocket (RFC 6455) client library for iOS, macOS and tvOS. Test results for SocketRocket here. You can compare to what mod

Facebook Incubator 9.4k Dec 27, 2022
Cross-platform JsonRPC client implementation with HTTP and WebSocket support

JsonRPC.swift Cross-platform JsonRPC client implementation with HTTP and WebSocket support Getting started Installation Package Manager Add the follow

Tesseract 5 Oct 19, 2022