Skip to content

Instantly share code, notes, and snippets.

//
// ShoppingCart.swift
// CombineShoppingCart
//
// Created by Piotr on 25/03/2020.
// Copyright © 2020 Piotr. All rights reserved.
//
import Combine
@pzmudzinski
pzmudzinski / CombineShoppingCartTests.swift
Last active May 20, 2021 01:39
CombineShoppingCartTests.swift
//
// CombineShoppingCartTests.swift
// CombineShoppingCartTests
//
// Created by Piotr on 25/03/2020.
// Copyright © 2020 Piotr. All rights reserved.
//
import XCTest
import Combine

Reactive Shopping Cart with Swift and Combine

Overview

Reactive programming was quite popular among iOS/OSX developers in recent years, although there was no "official" API. Community created wonderful RxSwit project, being one of most popular 3rd party tools used in Apple ecosystem. Things has changed little bit once Apple released their own Combine framework which introduced similar API and Rx-ish thinking.

Today, we are going to try it out via practical example of shopping cart functionality. We will be discussing how to model internal and external events happening in our buying process and thinking about posssible future extensions. Article assumes you have basic knowledge about swift and RxSwift or Combine.

Basics