remove NetworkOperationModel and NetworkOperationState
This commit is contained in:
parent
15a77a8bdb
commit
3e73ff7658
|
|
@ -1,7 +1,7 @@
|
|||
# Changelog
|
||||
|
||||
### 0.7.14
|
||||
- **Add**: `NetworkOperationState` and `RequestNetworkOperationModel` for tracking network request state. Just like `GeneralDataLoadingState` but without empty state.
|
||||
- **Add**: `RxNetworkOperationModel` base class, `NetworkOperationState` and `NetworkOperationStateType` protocols.
|
||||
|
||||
### 0.7.13
|
||||
- **Update**: Migrate from `Variable` to `BehaviorRelay`.
|
||||
|
|
|
|||
|
|
@ -29,14 +29,6 @@
|
|||
6713C24220AF189100875921 /* RxNetworkOperationModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6713C24020AF189100875921 /* RxNetworkOperationModel.swift */; };
|
||||
6713C24320AF189100875921 /* RxNetworkOperationModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6713C24020AF189100875921 /* RxNetworkOperationModel.swift */; };
|
||||
6713C24420AF189100875921 /* RxNetworkOperationModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6713C24020AF189100875921 /* RxNetworkOperationModel.swift */; };
|
||||
6713C24720AF1A0100875921 /* RequestNetworkOperationState.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6713C24620AF1A0100875921 /* RequestNetworkOperationState.swift */; };
|
||||
6713C24820AF1A0100875921 /* RequestNetworkOperationState.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6713C24620AF1A0100875921 /* RequestNetworkOperationState.swift */; };
|
||||
6713C24920AF1A0100875921 /* RequestNetworkOperationState.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6713C24620AF1A0100875921 /* RequestNetworkOperationState.swift */; };
|
||||
6713C24A20AF1A0100875921 /* RequestNetworkOperationState.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6713C24620AF1A0100875921 /* RequestNetworkOperationState.swift */; };
|
||||
6713C24D20AF1AA200875921 /* RequestNetworkOperationModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6713C24C20AF1AA200875921 /* RequestNetworkOperationModel.swift */; };
|
||||
6713C24E20AF1AA200875921 /* RequestNetworkOperationModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6713C24C20AF1AA200875921 /* RequestNetworkOperationModel.swift */; };
|
||||
6713C24F20AF1AA200875921 /* RequestNetworkOperationModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6713C24C20AF1AA200875921 /* RequestNetworkOperationModel.swift */; };
|
||||
6713C25020AF1AA200875921 /* RequestNetworkOperationModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6713C24C20AF1AA200875921 /* RequestNetworkOperationModel.swift */; };
|
||||
671462481EB3396E00EAB194 /* FixedPageCursor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 671461C81EB3396E00EAB194 /* FixedPageCursor.swift */; };
|
||||
671462491EB3396E00EAB194 /* FixedPageCursor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 671461C81EB3396E00EAB194 /* FixedPageCursor.swift */; };
|
||||
6714624A1EB3396E00EAB194 /* FixedPageCursor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 671461C81EB3396E00EAB194 /* FixedPageCursor.swift */; };
|
||||
|
|
@ -638,8 +630,6 @@
|
|||
6713C23620AF0C4D00875921 /* NetworkOperationState.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NetworkOperationState.swift; sourceTree = "<group>"; };
|
||||
6713C23B20AF0D5900875921 /* NetworkOperationModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NetworkOperationModel.swift; sourceTree = "<group>"; };
|
||||
6713C24020AF189100875921 /* RxNetworkOperationModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RxNetworkOperationModel.swift; sourceTree = "<group>"; };
|
||||
6713C24620AF1A0100875921 /* RequestNetworkOperationState.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RequestNetworkOperationState.swift; sourceTree = "<group>"; };
|
||||
6713C24C20AF1AA200875921 /* RequestNetworkOperationModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RequestNetworkOperationModel.swift; sourceTree = "<group>"; };
|
||||
671461C81EB3396E00EAB194 /* FixedPageCursor.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FixedPageCursor.swift; sourceTree = "<group>"; };
|
||||
671461C91EB3396E00EAB194 /* MapCursor.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MapCursor.swift; sourceTree = "<group>"; };
|
||||
671461CA1EB3396E00EAB194 /* StaticCursor.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StaticCursor.swift; sourceTree = "<group>"; };
|
||||
|
|
@ -899,22 +889,6 @@
|
|||
path = UITableView;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
6713C24520AF19DE00875921 /* RequestNetworkOperation */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
6713C24C20AF1AA200875921 /* RequestNetworkOperationModel.swift */,
|
||||
);
|
||||
path = RequestNetworkOperation;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
6713C24B20AF1A7A00875921 /* RequestNetworkOperation */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
6713C24620AF1A0100875921 /* RequestNetworkOperationState.swift */,
|
||||
);
|
||||
path = RequestNetworkOperation;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
671461C41EB3396E00EAB194 /* Classes */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
|
|
@ -1519,7 +1493,6 @@
|
|||
671461C71EB3396E00EAB194 /* Cursors */,
|
||||
6774529620625DA80024EEEF /* GeneralDataLoading */,
|
||||
671461CF1EB3396E00EAB194 /* PaginationDataLoading */,
|
||||
6713C24520AF19DE00875921 /* RequestNetworkOperation */,
|
||||
6774527F206256A20024EEEF /* RxDataLoadingModel.swift */,
|
||||
6713C24020AF189100875921 /* RxNetworkOperationModel.swift */,
|
||||
);
|
||||
|
|
@ -1543,7 +1516,6 @@
|
|||
children = (
|
||||
6774528B20625C8D0024EEEF /* GeneralDataLoading */,
|
||||
6774529820625E290024EEEF /* PaginationDataLoading */,
|
||||
6713C24B20AF1A7A00875921 /* RequestNetworkOperation */,
|
||||
671461D71EB3396E00EAB194 /* CursorError.swift */,
|
||||
);
|
||||
path = DataLoading;
|
||||
|
|
@ -2675,11 +2647,9 @@
|
|||
67A1FF941EBCA65E00D6C89F /* CABasicAnimation+Rotation.swift in Sources */,
|
||||
82F8BB181F5DDED100C1061B /* Single+DeferredJust.swift in Sources */,
|
||||
671463301EB3396E00EAB194 /* CursorType.swift in Sources */,
|
||||
6713C24720AF1A0100875921 /* RequestNetworkOperationState.swift in Sources */,
|
||||
67FDC25F1FA310EA00C76A77 /* RequestError.swift in Sources */,
|
||||
67745268206249360024EEEF /* UITableView+PaginationWrappable.swift in Sources */,
|
||||
6714624C1EB3396E00EAB194 /* MapCursor.swift in Sources */,
|
||||
6713C24D20AF1AA200875921 /* RequestNetworkOperationModel.swift in Sources */,
|
||||
EFA4C66F20865126008C4DD8 /* UniversalMappable+SwiftStandard.swift in Sources */,
|
||||
A6C9A4FA1F8BBCF2009311CC /* EmptyCell.swift in Sources */,
|
||||
6737CFA3207220960063E056 /* SeparatorConfiguration+Extensions.swift in Sources */,
|
||||
|
|
@ -2878,7 +2848,6 @@
|
|||
67274774206CCF1200725163 /* ViewText.swift in Sources */,
|
||||
671462A21EB3396E00EAB194 /* Double+Rounding.swift in Sources */,
|
||||
67955D54206D216B0021ECD2 /* Singleton.swift in Sources */,
|
||||
6713C24F20AF1AA200875921 /* RequestNetworkOperationModel.swift in Sources */,
|
||||
67EB7FF32061682F00BDD9FB /* TotalCountCursorListingResult+DefaultTotalCountCursorListingResult.swift in Sources */,
|
||||
67EB7FED2061667900BDD9FB /* DefaultTotalCountCursorListingResult.swift in Sources */,
|
||||
6714637E1EB3396E00EAB194 /* ImageDrawingOperation.swift in Sources */,
|
||||
|
|
@ -2900,7 +2869,6 @@
|
|||
67153E42207DFBA80049D8C0 /* FloatingPoint+DegreesRadiansConvertion.swift in Sources */,
|
||||
671462BA1EB3396E00EAB194 /* Sequence+ConcurrentMap.swift in Sources */,
|
||||
671463761EB3396E00EAB194 /* BorderDrawingOperation.swift in Sources */,
|
||||
6713C24920AF1A0100875921 /* RequestNetworkOperationState.swift in Sources */,
|
||||
677452A120625EEE0024EEEF /* PaginationDataLoadingModel.swift in Sources */,
|
||||
675C1FB51F97CA33007D5249 /* AppearanceConfigurable.swift in Sources */,
|
||||
6714628E1EB3396E00EAB194 /* CGImage+Alpha.swift in Sources */,
|
||||
|
|
@ -2955,7 +2923,6 @@
|
|||
67CAF8C920652E2A00527085 /* TextFieldViewModel.swift in Sources */,
|
||||
6714629B1EB3396E00EAB194 /* CGSize+Resize.swift in Sources */,
|
||||
671463331EB3396E00EAB194 /* CursorType.swift in Sources */,
|
||||
6713C24A20AF1A0100875921 /* RequestNetworkOperationState.swift in Sources */,
|
||||
6714624F1EB3396E00EAB194 /* MapCursor.swift in Sources */,
|
||||
671463271EB3396E00EAB194 /* Any+TypeName.swift in Sources */,
|
||||
67EB7FD220615B8900BDD9FB /* TotalCountCursorConfiguration.swift in Sources */,
|
||||
|
|
@ -3009,7 +2976,6 @@
|
|||
6792623E206EB0EC00308E62 /* CellSeparatorType+Extensions.swift in Sources */,
|
||||
6714626F1EB3396E00EAB194 /* XibView.swift in Sources */,
|
||||
6714637F1EB3396E00EAB194 /* ImageDrawingOperation.swift in Sources */,
|
||||
6713C25020AF1AA200875921 /* RequestNetworkOperationModel.swift in Sources */,
|
||||
67EB7FD720615D1700BDD9FB /* ResettableCursorType.swift in Sources */,
|
||||
671463371EB3396E00EAB194 /* DrawingOperation.swift in Sources */,
|
||||
67153E3D207DFADA0049D8C0 /* RotateDrawingOperation.swift in Sources */,
|
||||
|
|
@ -3141,7 +3107,6 @@
|
|||
671462AD1EB3396E00EAB194 /* Observable+DeferredJust.swift in Sources */,
|
||||
671463011EB3396E00EAB194 /* UIView+LoadFromNib.swift in Sources */,
|
||||
6774526D206249E30024EEEF /* UICollectionView+PaginationWrappable.swift in Sources */,
|
||||
6713C24E20AF1AA200875921 /* RequestNetworkOperationModel.swift in Sources */,
|
||||
6714627D1EB3396E00EAB194 /* AlamofireManager+Extensions.swift in Sources */,
|
||||
673CF4352063E29B00C329F6 /* TextWithButtonPlaceholder.swift in Sources */,
|
||||
67EB8002206177D600BDD9FB /* PaginationWrapperDelegate.swift in Sources */,
|
||||
|
|
@ -3213,7 +3178,6 @@
|
|||
671462751EB3396E00EAB194 /* LeadKitError.swift in Sources */,
|
||||
EFBE57D11EC35EF20040E00A /* Array+Extensions.swift in Sources */,
|
||||
676B22A3206A626D002E9F8A /* NSAttributedString+Extensions.swift in Sources */,
|
||||
6713C24820AF1A0100875921 /* RequestNetworkOperationState.swift in Sources */,
|
||||
671462D91EB3396E00EAB194 /* TimeInterval+DateComponents.swift in Sources */,
|
||||
6714638D1EB3396E00EAB194 /* SolidFillDrawingOperation.swift in Sources */,
|
||||
671463A31EB33FF600EAB194 /* Animatable.swift in Sources */,
|
||||
|
|
|
|||
|
|
@ -1,32 +0,0 @@
|
|||
//
|
||||
// Copyright (c) 2018 Touch Instinct
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the Software), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
//
|
||||
|
||||
import RxSwift
|
||||
|
||||
/// Network operation model for RequestNetworkOperationState with Single as data source.
|
||||
public final class RequestNetworkOperationModel<T>: RxNetworkOperationModel<RequestNetworkOperationState<Single<T>>> {
|
||||
|
||||
public override func execute() {
|
||||
super.execute() // just to make it public
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,86 +0,0 @@
|
|||
//
|
||||
// Copyright (c) 2018 Touch Instinct
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the Software), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
//
|
||||
|
||||
/// Enum that contains states for network operation request.
|
||||
///
|
||||
/// - initial: Initial state. Before something will happen.
|
||||
/// - processing: Loading state. When request is started.
|
||||
/// - done: Result state with result.
|
||||
/// - failed: Error state with a specific error.
|
||||
public enum RequestNetworkOperationState<DS: DataSource>: NetworkOperationState {
|
||||
|
||||
case initial
|
||||
case processing
|
||||
case done(result: DS.ResultType)
|
||||
case failed(error: Error)
|
||||
|
||||
public typealias DataSourceType = DS
|
||||
|
||||
public static var initialState: RequestNetworkOperationState<DS> {
|
||||
return .initial
|
||||
}
|
||||
|
||||
public static func initialLoadingState(after: RequestNetworkOperationState<DS>) -> RequestNetworkOperationState<DS> {
|
||||
return .processing
|
||||
}
|
||||
|
||||
public static func resultState(result: DS.ResultType,
|
||||
from: DS,
|
||||
after: RequestNetworkOperationState<DS>) -> RequestNetworkOperationState<DS> {
|
||||
|
||||
return .done(result: result)
|
||||
}
|
||||
|
||||
public static func errorState(error: Error,
|
||||
after: RequestNetworkOperationState<DS>) -> RequestNetworkOperationState<DS> {
|
||||
|
||||
return .failed(error: error)
|
||||
}
|
||||
|
||||
public var isInitialState: Bool {
|
||||
switch self {
|
||||
case .initial:
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
public var result: DS.ResultType? {
|
||||
switch self {
|
||||
case .done(let result):
|
||||
return result
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
public var error: Error? {
|
||||
switch self {
|
||||
case .failed(let error):
|
||||
return error
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue