Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TCA using combine #113

Draft
wants to merge 20 commits into
base: feature/rxtca-0.52.0
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//
// File.swift
//
//
// Created by Jefferson Setiawan on 15/08/24.
//

import IdentifiedCollections

extension IdentifiedArrayOf where Element: Identifiable, Element.ID == ID {
public func removeDuplicates() -> Self {
/// This table will contain `diffIdentifier` as the `key` and object `type` as the value
var tableOfObjectType = [AnyHashable: Any.Type]()

var uniqueObjects = IdentifiedArrayOf<Element>()

forEach { currentObject in
/// Get current object identifier
let currentId = currentObject.id

/// Get current object type from Type Erasure base object
let currentObjectType = type(of: currentObject)

/// Check if `currentId` is already registered on `Table Bank of Identifiers Type`
/// If `yes` > Get object type with current identifier from `Table Bank of Identifiers Type`
/// If `no` > Then return `nil`
let previousObjectType = tableOfObjectType[currentId]

/// Check whether current object type is the same with previous object type(if exist) fetched from `Table Bank of Identifiers Type`
/// If `currentId` already exist on `Table Bank of Identifiers Type` but the type is different it's not counted as _**duplicates**_
if currentObjectType != previousObjectType {
tableOfObjectType[currentId] = currentObjectType
uniqueObjects.append(currentObject)
}
}

return uniqueObjects
}
}
347 changes: 0 additions & 347 deletions Sources/RxComposableArchitecture/IdentifiedArray.swift

This file was deleted.

Loading