From c69527f585289ece9bc1f7e66801e4ceb921ff6e Mon Sep 17 00:00:00 2001 From: Taehyeon-Kim Date: Wed, 5 May 2021 14:01:03 +0900 Subject: [PATCH] =?UTF-8?q?add:=20Filtering=20Operator=20=EC=8B=A4?= =?UTF-8?q?=EC=8A=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Operator 중 필터링 연산자 실습 추가 --- .gitignore | 75 +++- Example/RxSwift-Filtering-Operators/Podfile | 10 + .../RxSwift-Filtering-Operators/Podfile.lock | 16 + .../project.pbxproj | 419 ++++++++++++++++++ .../contents.xcworkspacedata | 7 + .../xcshareddata/IDEWorkspaceChecks.plist | 8 + .../contents.xcworkspacedata | 10 + .../xcshareddata/IDEWorkspaceChecks.plist | 8 + .../AppDelegate.swift | 36 ++ .../AccentColor.colorset/Contents.json | 11 + .../AppIcon.appiconset/Contents.json | 98 ++++ .../Assets.xcassets/Contents.json | 6 + .../Base.lproj/LaunchScreen.storyboard | 25 ++ .../Base.lproj/Main.storyboard | 142 ++++++ .../RxSwift-Filtering-Operators/Info.plist | 64 +++ .../SceneDelegate.swift | 52 +++ .../ViewController.swift | 200 +++++++++ 17 files changed, 1176 insertions(+), 11 deletions(-) create mode 100644 Example/RxSwift-Filtering-Operators/Podfile create mode 100644 Example/RxSwift-Filtering-Operators/Podfile.lock create mode 100644 Example/RxSwift-Filtering-Operators/RxSwift-Filtering-Operators.xcodeproj/project.pbxproj create mode 100644 Example/RxSwift-Filtering-Operators/RxSwift-Filtering-Operators.xcodeproj/project.xcworkspace/contents.xcworkspacedata create mode 100644 Example/RxSwift-Filtering-Operators/RxSwift-Filtering-Operators.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist create mode 100644 Example/RxSwift-Filtering-Operators/RxSwift-Filtering-Operators.xcworkspace/contents.xcworkspacedata create mode 100644 Example/RxSwift-Filtering-Operators/RxSwift-Filtering-Operators.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist create mode 100644 Example/RxSwift-Filtering-Operators/RxSwift-Filtering-Operators/AppDelegate.swift create mode 100644 Example/RxSwift-Filtering-Operators/RxSwift-Filtering-Operators/Assets.xcassets/AccentColor.colorset/Contents.json create mode 100644 Example/RxSwift-Filtering-Operators/RxSwift-Filtering-Operators/Assets.xcassets/AppIcon.appiconset/Contents.json create mode 100644 Example/RxSwift-Filtering-Operators/RxSwift-Filtering-Operators/Assets.xcassets/Contents.json create mode 100644 Example/RxSwift-Filtering-Operators/RxSwift-Filtering-Operators/Base.lproj/LaunchScreen.storyboard create mode 100644 Example/RxSwift-Filtering-Operators/RxSwift-Filtering-Operators/Base.lproj/Main.storyboard create mode 100644 Example/RxSwift-Filtering-Operators/RxSwift-Filtering-Operators/Info.plist create mode 100644 Example/RxSwift-Filtering-Operators/RxSwift-Filtering-Operators/SceneDelegate.swift create mode 100644 Example/RxSwift-Filtering-Operators/RxSwift-Filtering-Operators/ViewController.swift diff --git a/.gitignore b/.gitignore index 330d167..2257d2c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,45 @@ + +# Created by https://www.toptal.com/developers/gitignore/api/swift,xcode,macos,cocoapods +# Edit at https://www.toptal.com/developers/gitignore?templates=swift,xcode,macos,cocoapods + +### CocoaPods ### +## CocoaPods GitIgnore Template + +# CocoaPods - Only use to conserve bandwidth / Save time on Pushing +# - Also handy if you have a large number of dependant pods +# - AS PER https://guides.cocoapods.org/using/using-cocoapods.html NEVER IGNORE THE LOCK FILE +Pods/ + +### macOS ### +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +### Swift ### # Xcode # # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore @@ -35,13 +77,11 @@ timeline.xctimeline playground.xcworkspace # Swift Package Manager -# # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. # Packages/ # Package.pins # Package.resolved # *.xcodeproj -# # Xcode automatically generates this directory with a .xcworkspacedata file and xcuserdata # hence it is not needed unless you have added a package configuration file to your project # .swiftpm @@ -49,29 +89,24 @@ playground.xcworkspace .build/ # CocoaPods -# # We recommend against adding the Pods directory to your .gitignore. However # you should judge for yourself, the pros and cons are mentioned at: # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control -# # Pods/ -# # Add this line if you want to avoid checking in source code from the Xcode workspace # *.xcworkspace # Carthage -# # Add this line if you want to avoid checking in source code from Carthage dependencies. # Carthage/Checkouts Carthage/Build/ -# Accio dependency management -Dependencies/ -.accio/ +# Add this lines if you are using Accio dependency management (Deprecated since Xcode 12) +# Dependencies/ +# .accio/ # fastlane -# # It is recommended to not store the screenshots in the git repo. # Instead, use fastlane to re-generate the screenshots whenever they are needed. # For more information about the recommended setup visit: @@ -83,8 +118,26 @@ fastlane/screenshots/**/*.png fastlane/test_output # Code Injection -# # After new code Injection tools there's a generated folder /iOSInjectionProject # https://github.com/johnno1962/injectionforxcode iOSInjectionProject/ + +### Xcode ### +# Xcode +# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore + + + + +## Gcc Patch +/*.gcno + +### Xcode Patch ### +*.xcodeproj/* +!*.xcodeproj/project.pbxproj +!*.xcodeproj/xcshareddata/ +!*.xcworkspace/contents.xcworkspacedata +**/xcshareddata/WorkspaceSettings.xcsettings + +# End of https://www.toptal.com/developers/gitignore/api/swift,xcode,macos,cocoapods \ No newline at end of file diff --git a/Example/RxSwift-Filtering-Operators/Podfile b/Example/RxSwift-Filtering-Operators/Podfile new file mode 100644 index 0000000..7f35c90 --- /dev/null +++ b/Example/RxSwift-Filtering-Operators/Podfile @@ -0,0 +1,10 @@ +# Uncomment the next line to define a global platform for your project +# platform :ios, '9.0' + +target 'RxSwift-Filtering-Operators' do + # Comment the next line if you don't want to use dynamic frameworks + use_frameworks! + + # Pods for RxSwift-Filtering-Operators + pod 'RxSwift' +end diff --git a/Example/RxSwift-Filtering-Operators/Podfile.lock b/Example/RxSwift-Filtering-Operators/Podfile.lock new file mode 100644 index 0000000..e3be06f --- /dev/null +++ b/Example/RxSwift-Filtering-Operators/Podfile.lock @@ -0,0 +1,16 @@ +PODS: + - RxSwift (6.1.0) + +DEPENDENCIES: + - RxSwift + +SPEC REPOS: + trunk: + - RxSwift + +SPEC CHECKSUMS: + RxSwift: a834e5c538e89eca0cae86f403f4fbf0336786ce + +PODFILE CHECKSUM: 3a86af9ab5fa6e429abab90a6d81d43270b53390 + +COCOAPODS: 1.10.0 diff --git a/Example/RxSwift-Filtering-Operators/RxSwift-Filtering-Operators.xcodeproj/project.pbxproj b/Example/RxSwift-Filtering-Operators/RxSwift-Filtering-Operators.xcodeproj/project.pbxproj new file mode 100644 index 0000000..c8dc297 --- /dev/null +++ b/Example/RxSwift-Filtering-Operators/RxSwift-Filtering-Operators.xcodeproj/project.pbxproj @@ -0,0 +1,419 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 50; + objects = { + +/* Begin PBXBuildFile section */ + BD84D1E5264243FC0090D522 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD84D1E4264243FC0090D522 /* AppDelegate.swift */; }; + BD84D1E7264243FC0090D522 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD84D1E6264243FC0090D522 /* SceneDelegate.swift */; }; + BD84D1E9264243FC0090D522 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD84D1E8264243FC0090D522 /* ViewController.swift */; }; + BD84D1EC264243FC0090D522 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = BD84D1EA264243FC0090D522 /* Main.storyboard */; }; + BD84D1EE264243FE0090D522 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = BD84D1ED264243FE0090D522 /* Assets.xcassets */; }; + BD84D1F1264243FE0090D522 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = BD84D1EF264243FE0090D522 /* LaunchScreen.storyboard */; }; + DA0731BD65D065802D98E175 /* Pods_RxSwift_Filtering_Operators.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2E80C1FA858F93F6FCD5146B /* Pods_RxSwift_Filtering_Operators.framework */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 2E80C1FA858F93F6FCD5146B /* Pods_RxSwift_Filtering_Operators.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_RxSwift_Filtering_Operators.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 32250CF1DFF70152782210DC /* Pods-RxSwift-Filtering-Operators.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RxSwift-Filtering-Operators.debug.xcconfig"; path = "Target Support Files/Pods-RxSwift-Filtering-Operators/Pods-RxSwift-Filtering-Operators.debug.xcconfig"; sourceTree = ""; }; + BD84D1E1264243FC0090D522 /* RxSwift-Filtering-Operators.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "RxSwift-Filtering-Operators.app"; sourceTree = BUILT_PRODUCTS_DIR; }; + BD84D1E4264243FC0090D522 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + BD84D1E6264243FC0090D522 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; + BD84D1E8264243FC0090D522 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; + BD84D1EB264243FC0090D522 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + BD84D1ED264243FE0090D522 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + BD84D1F0264243FE0090D522 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + BD84D1F2264243FE0090D522 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + E151FF20EF670E0B85017ED4 /* Pods-RxSwift-Filtering-Operators.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RxSwift-Filtering-Operators.release.xcconfig"; path = "Target Support Files/Pods-RxSwift-Filtering-Operators/Pods-RxSwift-Filtering-Operators.release.xcconfig"; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + BD84D1DE264243FC0090D522 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + DA0731BD65D065802D98E175 /* Pods_RxSwift_Filtering_Operators.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 4EB16B596AE4E95CDE87C9AB /* Pods */ = { + isa = PBXGroup; + children = ( + 32250CF1DFF70152782210DC /* Pods-RxSwift-Filtering-Operators.debug.xcconfig */, + E151FF20EF670E0B85017ED4 /* Pods-RxSwift-Filtering-Operators.release.xcconfig */, + ); + name = Pods; + path = Pods; + sourceTree = ""; + }; + BD84D1D8264243FC0090D522 = { + isa = PBXGroup; + children = ( + BD84D1E3264243FC0090D522 /* RxSwift-Filtering-Operators */, + BD84D1E2264243FC0090D522 /* Products */, + 4EB16B596AE4E95CDE87C9AB /* Pods */, + FF89B6F035153230CE107D90 /* Frameworks */, + ); + sourceTree = ""; + }; + BD84D1E2264243FC0090D522 /* Products */ = { + isa = PBXGroup; + children = ( + BD84D1E1264243FC0090D522 /* RxSwift-Filtering-Operators.app */, + ); + name = Products; + sourceTree = ""; + }; + BD84D1E3264243FC0090D522 /* RxSwift-Filtering-Operators */ = { + isa = PBXGroup; + children = ( + BD84D1E4264243FC0090D522 /* AppDelegate.swift */, + BD84D1E6264243FC0090D522 /* SceneDelegate.swift */, + BD84D1E8264243FC0090D522 /* ViewController.swift */, + BD84D1EA264243FC0090D522 /* Main.storyboard */, + BD84D1ED264243FE0090D522 /* Assets.xcassets */, + BD84D1EF264243FE0090D522 /* LaunchScreen.storyboard */, + BD84D1F2264243FE0090D522 /* Info.plist */, + ); + path = "RxSwift-Filtering-Operators"; + sourceTree = ""; + }; + FF89B6F035153230CE107D90 /* Frameworks */ = { + isa = PBXGroup; + children = ( + 2E80C1FA858F93F6FCD5146B /* Pods_RxSwift_Filtering_Operators.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + BD84D1E0264243FC0090D522 /* RxSwift-Filtering-Operators */ = { + isa = PBXNativeTarget; + buildConfigurationList = BD84D1F5264243FE0090D522 /* Build configuration list for PBXNativeTarget "RxSwift-Filtering-Operators" */; + buildPhases = ( + CB096F20774CA55FF5744911 /* [CP] Check Pods Manifest.lock */, + BD84D1DD264243FC0090D522 /* Sources */, + BD84D1DE264243FC0090D522 /* Frameworks */, + BD84D1DF264243FC0090D522 /* Resources */, + 86B0B1D0E4B0E2E16CA91B86 /* [CP] Embed Pods Frameworks */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = "RxSwift-Filtering-Operators"; + productName = "RxSwift-Filtering-Operators"; + productReference = BD84D1E1264243FC0090D522 /* RxSwift-Filtering-Operators.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + BD84D1D9264243FC0090D522 /* Project object */ = { + isa = PBXProject; + attributes = { + LastSwiftUpdateCheck = 1240; + LastUpgradeCheck = 1240; + TargetAttributes = { + BD84D1E0264243FC0090D522 = { + CreatedOnToolsVersion = 12.4; + }; + }; + }; + buildConfigurationList = BD84D1DC264243FC0090D522 /* Build configuration list for PBXProject "RxSwift-Filtering-Operators" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = BD84D1D8264243FC0090D522; + productRefGroup = BD84D1E2264243FC0090D522 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + BD84D1E0264243FC0090D522 /* RxSwift-Filtering-Operators */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + BD84D1DF264243FC0090D522 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + BD84D1F1264243FE0090D522 /* LaunchScreen.storyboard in Resources */, + BD84D1EE264243FE0090D522 /* Assets.xcassets in Resources */, + BD84D1EC264243FC0090D522 /* Main.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 86B0B1D0E4B0E2E16CA91B86 /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-RxSwift-Filtering-Operators/Pods-RxSwift-Filtering-Operators-frameworks-${CONFIGURATION}-input-files.xcfilelist", + ); + name = "[CP] Embed Pods Frameworks"; + outputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-RxSwift-Filtering-Operators/Pods-RxSwift-Filtering-Operators-frameworks-${CONFIGURATION}-output-files.xcfilelist", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-RxSwift-Filtering-Operators/Pods-RxSwift-Filtering-Operators-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; + CB096F20774CA55FF5744911 /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputFileListPaths = ( + ); + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-RxSwift-Filtering-Operators-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + BD84D1DD264243FC0090D522 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + BD84D1E9264243FC0090D522 /* ViewController.swift in Sources */, + BD84D1E5264243FC0090D522 /* AppDelegate.swift in Sources */, + BD84D1E7264243FC0090D522 /* SceneDelegate.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + BD84D1EA264243FC0090D522 /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + BD84D1EB264243FC0090D522 /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + BD84D1EF264243FE0090D522 /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + BD84D1F0264243FE0090D522 /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + BD84D1F3264243FE0090D522 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 14.4; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + BD84D1F4264243FE0090D522 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 14.4; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = iphoneos; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + BD84D1F6264243FE0090D522 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 32250CF1DFF70152782210DC /* Pods-RxSwift-Filtering-Operators.debug.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = W895YM7ZMH; + INFOPLIST_FILE = "RxSwift-Filtering-Operators/Info.plist"; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = "dev.taekki.ios.RxSwift-Filtering-Operators"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = 1; + }; + name = Debug; + }; + BD84D1F7264243FE0090D522 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = E151FF20EF670E0B85017ED4 /* Pods-RxSwift-Filtering-Operators.release.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = W895YM7ZMH; + INFOPLIST_FILE = "RxSwift-Filtering-Operators/Info.plist"; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = "dev.taekki.ios.RxSwift-Filtering-Operators"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = 1; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + BD84D1DC264243FC0090D522 /* Build configuration list for PBXProject "RxSwift-Filtering-Operators" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + BD84D1F3264243FE0090D522 /* Debug */, + BD84D1F4264243FE0090D522 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + BD84D1F5264243FE0090D522 /* Build configuration list for PBXNativeTarget "RxSwift-Filtering-Operators" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + BD84D1F6264243FE0090D522 /* Debug */, + BD84D1F7264243FE0090D522 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = BD84D1D9264243FC0090D522 /* Project object */; +} diff --git a/Example/RxSwift-Filtering-Operators/RxSwift-Filtering-Operators.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/Example/RxSwift-Filtering-Operators/RxSwift-Filtering-Operators.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..919434a --- /dev/null +++ b/Example/RxSwift-Filtering-Operators/RxSwift-Filtering-Operators.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/Example/RxSwift-Filtering-Operators/RxSwift-Filtering-Operators.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/Example/RxSwift-Filtering-Operators/RxSwift-Filtering-Operators.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/Example/RxSwift-Filtering-Operators/RxSwift-Filtering-Operators.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/Example/RxSwift-Filtering-Operators/RxSwift-Filtering-Operators.xcworkspace/contents.xcworkspacedata b/Example/RxSwift-Filtering-Operators/RxSwift-Filtering-Operators.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..e9c9d61 --- /dev/null +++ b/Example/RxSwift-Filtering-Operators/RxSwift-Filtering-Operators.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,10 @@ + + + + + + + diff --git a/Example/RxSwift-Filtering-Operators/RxSwift-Filtering-Operators.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/Example/RxSwift-Filtering-Operators/RxSwift-Filtering-Operators.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/Example/RxSwift-Filtering-Operators/RxSwift-Filtering-Operators.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/Example/RxSwift-Filtering-Operators/RxSwift-Filtering-Operators/AppDelegate.swift b/Example/RxSwift-Filtering-Operators/RxSwift-Filtering-Operators/AppDelegate.swift new file mode 100644 index 0000000..b2406ed --- /dev/null +++ b/Example/RxSwift-Filtering-Operators/RxSwift-Filtering-Operators/AppDelegate.swift @@ -0,0 +1,36 @@ +// +// AppDelegate.swift +// RxSwift-Filtering-Operators +// +// Created by taehy.k on 2021/05/05. +// + +import UIKit + +@main +class AppDelegate: UIResponder, UIApplicationDelegate { + + + + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { + // Override point for customization after application launch. + return true + } + + // MARK: UISceneSession Lifecycle + + func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { + // Called when a new scene session is being created. + // Use this method to select a configuration to create the new scene with. + return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role) + } + + func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set) { + // Called when the user discards a scene session. + // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions. + // Use this method to release any resources that were specific to the discarded scenes, as they will not return. + } + + +} + diff --git a/Example/RxSwift-Filtering-Operators/RxSwift-Filtering-Operators/Assets.xcassets/AccentColor.colorset/Contents.json b/Example/RxSwift-Filtering-Operators/RxSwift-Filtering-Operators/Assets.xcassets/AccentColor.colorset/Contents.json new file mode 100644 index 0000000..eb87897 --- /dev/null +++ b/Example/RxSwift-Filtering-Operators/RxSwift-Filtering-Operators/Assets.xcassets/AccentColor.colorset/Contents.json @@ -0,0 +1,11 @@ +{ + "colors" : [ + { + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Example/RxSwift-Filtering-Operators/RxSwift-Filtering-Operators/Assets.xcassets/AppIcon.appiconset/Contents.json b/Example/RxSwift-Filtering-Operators/RxSwift-Filtering-Operators/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..9221b9b --- /dev/null +++ b/Example/RxSwift-Filtering-Operators/RxSwift-Filtering-Operators/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,98 @@ +{ + "images" : [ + { + "idiom" : "iphone", + "scale" : "2x", + "size" : "20x20" + }, + { + "idiom" : "iphone", + "scale" : "3x", + "size" : "20x20" + }, + { + "idiom" : "iphone", + "scale" : "2x", + "size" : "29x29" + }, + { + "idiom" : "iphone", + "scale" : "3x", + "size" : "29x29" + }, + { + "idiom" : "iphone", + "scale" : "2x", + "size" : "40x40" + }, + { + "idiom" : "iphone", + "scale" : "3x", + "size" : "40x40" + }, + { + "idiom" : "iphone", + "scale" : "2x", + "size" : "60x60" + }, + { + "idiom" : "iphone", + "scale" : "3x", + "size" : "60x60" + }, + { + "idiom" : "ipad", + "scale" : "1x", + "size" : "20x20" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "20x20" + }, + { + "idiom" : "ipad", + "scale" : "1x", + "size" : "29x29" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "29x29" + }, + { + "idiom" : "ipad", + "scale" : "1x", + "size" : "40x40" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "40x40" + }, + { + "idiom" : "ipad", + "scale" : "1x", + "size" : "76x76" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "76x76" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "83.5x83.5" + }, + { + "idiom" : "ios-marketing", + "scale" : "1x", + "size" : "1024x1024" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Example/RxSwift-Filtering-Operators/RxSwift-Filtering-Operators/Assets.xcassets/Contents.json b/Example/RxSwift-Filtering-Operators/RxSwift-Filtering-Operators/Assets.xcassets/Contents.json new file mode 100644 index 0000000..73c0059 --- /dev/null +++ b/Example/RxSwift-Filtering-Operators/RxSwift-Filtering-Operators/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Example/RxSwift-Filtering-Operators/RxSwift-Filtering-Operators/Base.lproj/LaunchScreen.storyboard b/Example/RxSwift-Filtering-Operators/RxSwift-Filtering-Operators/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 0000000..865e932 --- /dev/null +++ b/Example/RxSwift-Filtering-Operators/RxSwift-Filtering-Operators/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Example/RxSwift-Filtering-Operators/RxSwift-Filtering-Operators/Base.lproj/Main.storyboard b/Example/RxSwift-Filtering-Operators/RxSwift-Filtering-Operators/Base.lproj/Main.storyboard new file mode 100644 index 0000000..08c598e --- /dev/null +++ b/Example/RxSwift-Filtering-Operators/RxSwift-Filtering-Operators/Base.lproj/Main.storyboard @@ -0,0 +1,142 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Example/RxSwift-Filtering-Operators/RxSwift-Filtering-Operators/Info.plist b/Example/RxSwift-Filtering-Operators/RxSwift-Filtering-Operators/Info.plist new file mode 100644 index 0000000..2b43ebc --- /dev/null +++ b/Example/RxSwift-Filtering-Operators/RxSwift-Filtering-Operators/Info.plist @@ -0,0 +1,64 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + $(PRODUCT_BUNDLE_PACKAGE_TYPE) + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + LSRequiresIPhoneOS + + UIApplicationSceneManifest + + UIApplicationSupportsMultipleScenes + + UISceneConfigurations + + UIWindowSceneSessionRoleApplication + + + UISceneConfigurationName + Default Configuration + UISceneDelegateClassName + $(PRODUCT_MODULE_NAME).SceneDelegate + UISceneStoryboardFile + Main + + + + + UIApplicationSupportsIndirectInputEvents + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git a/Example/RxSwift-Filtering-Operators/RxSwift-Filtering-Operators/SceneDelegate.swift b/Example/RxSwift-Filtering-Operators/RxSwift-Filtering-Operators/SceneDelegate.swift new file mode 100644 index 0000000..a491606 --- /dev/null +++ b/Example/RxSwift-Filtering-Operators/RxSwift-Filtering-Operators/SceneDelegate.swift @@ -0,0 +1,52 @@ +// +// SceneDelegate.swift +// RxSwift-Filtering-Operators +// +// Created by taehy.k on 2021/05/05. +// + +import UIKit + +class SceneDelegate: UIResponder, UIWindowSceneDelegate { + + var window: UIWindow? + + + func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { + // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`. + // If using a storyboard, the `window` property will automatically be initialized and attached to the scene. + // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead). + guard let _ = (scene as? UIWindowScene) else { return } + } + + func sceneDidDisconnect(_ scene: UIScene) { + // Called as the scene is being released by the system. + // This occurs shortly after the scene enters the background, or when its session is discarded. + // Release any resources associated with this scene that can be re-created the next time the scene connects. + // The scene may re-connect later, as its session was not necessarily discarded (see `application:didDiscardSceneSessions` instead). + } + + func sceneDidBecomeActive(_ scene: UIScene) { + // Called when the scene has moved from an inactive state to an active state. + // Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive. + } + + func sceneWillResignActive(_ scene: UIScene) { + // Called when the scene will move from an active state to an inactive state. + // This may occur due to temporary interruptions (ex. an incoming phone call). + } + + func sceneWillEnterForeground(_ scene: UIScene) { + // Called as the scene transitions from the background to the foreground. + // Use this method to undo the changes made on entering the background. + } + + func sceneDidEnterBackground(_ scene: UIScene) { + // Called as the scene transitions from the foreground to the background. + // Use this method to save data, release shared resources, and store enough scene-specific state information + // to restore the scene back to its current state. + } + + +} + diff --git a/Example/RxSwift-Filtering-Operators/RxSwift-Filtering-Operators/ViewController.swift b/Example/RxSwift-Filtering-Operators/RxSwift-Filtering-Operators/ViewController.swift new file mode 100644 index 0000000..03c7849 --- /dev/null +++ b/Example/RxSwift-Filtering-Operators/RxSwift-Filtering-Operators/ViewController.swift @@ -0,0 +1,200 @@ +// +// ViewController.swift +// RxSwift-Filtering-Operators +// +// Created by taehy.k on 2021/05/05. +// + +import UIKit +import RxSwift + +class ViewController: UIViewController { + + // MARK: - Properties + + var disposeBag = DisposeBag() + + // MARK: - Life Cycle + + override func viewDidLoad() { + super.viewDidLoad() + // Do any additional setup after loading the view. + } + + // MARK: - Ignore Action (무시하기 ~) + + // ignoreElements() + // - subscribe 하고 있는 라인에서 어떠한 데이터도 이벤트도 전달받지 못하고 무시된다. + // -- .next이벤트를 무시한다. + // - 종료(.completed)나 에러(.error)와 같은 정지 이벤트만 하용된다. + @IBAction func ignoreElementsTapped(_ sender: Any) { + let strikes:[String] = ["X", "X", "X"] + + Observable.from(strikes) + .ignoreElements() + .subscribe(onNext: { _ in +// print("(event) you're out!") + }, onCompleted: { + print("(complete) you're out!") + }) + .disposed(by: disposeBag) + } + + // elementAt + // - 특정 요소만 처리하고 싶을 때 사용한다. + // - 다음 예시에서는 1번째 원소는 스트림에 값이 넘어가는 것을 확인할 수 있다. + @IBAction func elementAtTapped(_ sender: Any) { + let strikes:[String] = ["1X", "2X", "3X"] + + Observable.from(strikes) + .element(at: 1) + .subscribe(onNext : { n in + print("\(n) You're out!") + }) + .disposed(by: disposeBag) + } + + // filter() + // - 말 그대로 데이터를 걸러준다는 느낌이 드는 오퍼레이터 + // - 곰튀김님 4시간 강좌에서 예시 코드 등장 + @IBAction func filterTapped(_ sender: Any) { + Observable.from([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) + // True일때만 값을 밑으로 내려보내고, False일때는 내려보내지 않는다. + .filter{ $0 % 2 == 0 } + .subscribe(onNext: { n in + print(n) + }) + .disposed(by: disposeBag) + } + + // MARK: - Skip Action (건너띄기~) + + // skip() + // - 원하는 n개의 요소를 skip하고 싶을 때 사용하는 오퍼레이터 + // - 선착순 3명 제외하고, 나머지 1명은 벌칙을 줄거야 + @IBAction func skipTapped(_ sender: Any) { + Observable.from(["사람1", "사람2", "사람3", "사람4"]) + .skip(3) + .subscribe(onNext: { + print("\($0)는 벌칙준비해라") + }) + .disposed(by: disposeBag) + } + + // skipWhile() (= .skip(while: _)) + // - filter와 유사 + // - filter와 반대로 검사를 통과하지 못한(False) 요소를 전달!! + // ‼️ 중요한건 검사를 통과하지 못한 요소 이후부터는 T/F 관계없이 전부 전달 + // - cf) filter는 검사를 통과한(True) 요소만 전달 + @IBAction func skipWhileTapped(_ sender: Any) { + Observable.of(2,2,3,4,4) + // 짝수인지 검사하고, 홀수가 나온 순간부터는 전부 전달 + .skip(while: { $0 % 2 == 0 }) + .subscribe(onNext: { + print($0) + }) + .disposed(by: disposeBag) + } + + // skipUntil() (= .skip(until: _)) + @IBAction func skipUntilTapped(_ sender: Any) { + // 옵저버블 2개 생성 + let subject = PublishSubject() + let trigger = PublishSubject() + + subject + .skip(until: trigger) + .subscribe(onNext: { + print($0) + }) + .disposed(by: disposeBag) + + // 여기까지는 다 무시되겠져? + subject.onNext("A") + subject.onNext("B") + + // skip 종료! + // 왜냐면 다른 옵저버블이 요소를 emit(방출)했기 때문! + trigger.onNext("X") + + subject.onNext("C") + } + + // take() + // - skip()이랑 반대되는 개념으로 n번째 요소까지 방출한다. + // - 앞에 2명나와라 + @IBAction func takeTapped(_ sender: Any) { + Observable.from(["은영", "지원", "태현", "혜령"]) + .take(2) + .subscribe(onNext: { + print("\($0) ✋") + }) + .disposed(by: disposeBag) + } + + // takeWhile() + // - 약간 디버깅의 중단점같은 느낌인 것 같아요. + @IBAction func takeWhileTapped(_ sender: Any) { + Observable.from(["성공", "성공", "에러", "성공", "성공"]) + .take(while: { $0 != "에러" }) + .subscribe(onNext: { + print($0) + }) + .disposed(by: disposeBag) + } + + // enumerated() + // - 이 친구는 파이썬을 했다면 정말 자주 보았겠지만, 그렇지 않을 수 있으니 + // [a,b,c,d,e]의 배열이 있을 때 요소의 값 뿐만 아니라 인덱스도 같이 참조하고 싶을 때!! + @IBAction func enumeratedTapped(_ sender: Any) { + Observable.of(2,2,4,4,6,6) + .enumerated() + .take(while: { index, value in + value % 2 == 0 && index < 3 + }) +// .map { $0.element } + .subscribe(onNext: { + print($0) + }) + .disposed(by: disposeBag) + } + + // takeUntil() + @IBAction func takeUntilTapped(_ sender: Any) { + // 옵저버블 2개 생성 + let subject = PublishSubject() + let trigger = PublishSubject() + + subject + .take(until: trigger) + .subscribe(onNext: { + print($0) + }) + .disposed(by: disposeBag) + + // 여기까지는 다 출력되겠죠!>! + subject.onNext("A") + subject.onNext("B") + subject.onNext("B") + subject.onNext("C") + + // take 종료! + // 왜냐면 다른 옵저버블이 요소를 emit(방출)했기 때문! + trigger.onNext("X") + + subject.onNext("C") + } + + // distinctUntilChanged() + // - 연달아 이어지는, 중복되는 값을 막아주는 역할을 한다. + @IBAction func distinctUntilChangedTapped(_ sender: Any) { + Observable.of("A", "A", "B", "B", "C", "C", "A") + // 중복제거 + .distinctUntilChanged() + .subscribe(onNext: { + print($0) + }) + .disposed(by: disposeBag) + } +} +