Skip to content

๐Ÿ‡ฐ๐Ÿ‡ท ์ž์‹ ์˜ ํ•™๊ต ๊ธ‰์‹์„ ๊ฐ€์ ธ์˜ฌ ์ˆ˜ ์žˆ๋Š” ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ์ž…๋‹ˆ๋‹ค!

License

kimxwan0319/RxSchoolMeal

Repository files navigation

RxSchoolMeal

CI Version Carthage compatible Swift Package Manager License Platform codecov

Usage

์ดˆ๊ธฐํ™”

iOS ์•ฑ์—์„œ RxSchoolMeal๋ฅผ ์‚ฌ์šฉํ•˜๋ ค๋ฉด RxSchoolMeal ํŒŒ์ผ์„ ์•„๋ž˜์™€ ๊ฐ™์ด ์ž„ํฌํŠธ(import)ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. ๋˜ํ•œ ํ•™๊ต์ด๋ฆ„์„ ์ด์šฉํ•ด RxSchoolMeal๋ฅผ ์ดˆ๊ธฐํ™” ํ•˜๋Š” ๊ณผ์ •์ด ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค. ๋‹ค์Œ ์˜ˆ์ œ๋ฅผ ์ฐธ๊ณ ํ•˜์—ฌ AppDelegate.swift์— RxSchoolMeal๋ฅผ ์ดˆ๊ธฐํ™”ํ•˜๋Š” ์ฝ”๋“œ๋ฅผ ์ถ”๊ฐ€ํ•ฉ๋‹ˆ๋‹ค.

import RxSchoolMeal 

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { 

ใ…ค... 
    SchoolCommon.initSchool(schoolName: <#ํ•™๊ต์ด๋ฆ„#>)
ใ…ค... 
ใ…ค
}

๊ธ‰์‹ ์ •๋ณด ๊ฐ€์ ธ์˜ค๊ธฐ

๊ธ‰์‹ ์ •๋ณด๋ฅผ ๊ฐ€์ ธ์˜ค๋Š” ์ฝ”๋“œ์˜ ๊ธฐ๋ณธ์ ์ธ ํ˜•ํƒœ์ž…๋‹ˆ๋‹ค.

MEAL.getMeal(<#๋‚ ์งœ#>, timePart: <#์‹์‚ฌ๊ตฌ๋ถ„#>).subscribe(onSuccess: { meal in
    print(meal)
})
.disposed(by: disposeBag)
  • ์œ„ <#๋‚ ์งœ#>๋ผ๊ณ  ์ž‘์„ฑ ๋˜์–ด์žˆ๋Š” ๋ถ€๋ถ„์—๋Š” MealDate๋ผ๋Š” ์ด๋ฆ„์œผ๋กœ ์ •์˜๋œ enum์„ ์ž…๋ ฅํ•ฉ๋‹ˆ๋‹ค.
    Raw Value Description
    .today ์˜ค๋Š˜์„ ๋‚˜ํƒ€๋ƒ…๋‹ˆ๋‹ค.
    .anotherDate(date: Date) ์›ํ•˜๋Š” ๋‚ ์งœ๋ฅผ Date ํƒ€์ž…์œผ๋กœ ๋ฐ›์Šต๋‹ˆ๋‹ค.
    .plusMinusDay(day: Int) ์˜ค๋Š˜์„ ๊ธฐ์ค€์œผ๋กœ ์กฐํšŒํ•˜๊ณ  ์‹ถ์€ ๋‚ ์งœ๊ฐ€ ๋ช‡์ผ ํ›„์ธ์ง€, ๋ช‡์ผ ์ „์ธ์ง€๋ฅผ Intํ˜•์‹์œผ๋กœ ๋ฐ›์Šต๋‹ˆ๋‹ค.
  • ์œ„ getMeal() ํ•จ์ˆ˜๋Š” timePart: <#์‹์‚ฌ๊ตฌ๋ถ„#> ๋ถ€๋ถ„์„ ์ž‘์„ฑํ•˜์ง€ ์•Š์•„๋„ ๋˜๋„๋ก ์˜ค๋ฒ„๋กœ๋”ฉ ๋˜์–ด์žˆ์Šต๋‹ˆ๋‹ค. ๋งŒ์•ฝ MealModel๋ผ๋Š” ์ด๋ฆ„์œผ๋กœ ์ •์˜๋œ struct๋กœ ์•„์นจ, ์ ์‹ฌ, ์ €๋… ๋ฉ”๋‰ด๋ฅผ ๋ชจ๋‘ ๋ฐ›๊ณ ์‹ถ๋‹ค๋ฉด ์ž‘์„ฑํ•˜์ง€ ์•Š์œผ์‹œ๋ฉด ๋ฉ๋‹ˆ๋‹ค. ํ•˜์ง€๋งŒ ์•„์นจ, ์ ์‹ฌ, ์ €๋…์ค‘ ํ•˜๋‚˜๋ฅผ [String]ํ˜•ํƒœ๋กœ ๋ฐ›์•„๋ณด๊ณ  ์‹ถ๋‹ค๋ฉด ์ž‘์„ฑํ•˜์‹œ๋ฉด ๋ฉ๋‹ˆ๋‹ค.
  • <#์‹์‚ฌ๊ตฌ๋ถ„#> ๋ผ๊ณ  ์ž‘์„ฑ ๋˜์–ด์žˆ๋Š” ๋ถ€๋ถ„์—๋Š” MealPartTime์ด๋ผ๋Š” ์ด๋ฆ„์œผ๋กœ ์ •์˜๋œ enum์„ ์ž…๋ ฅํ•ฉ๋‹ˆ๋‹ค.
    Raw Value Description
    .breakfast ์•„์นจ๋ฐฅ ์ž…๋‹ˆ๋‹ค.
    .lunch ์ ์‹ฌ๋ฐฅ ์ž…๋‹ˆ๋‹ค.
    .dinner ์ €๋…๋ฐฅ ์ž…๋‹ˆ๋‹ค.
Examples

์•„๋ž˜ ์„ธ ์˜ˆ์ œ๋Š” ๋ชจ๋‘ ์˜ค๋Š˜์˜ ๊ธ‰์‹์„ ์กฐํšŒํ•ฉ๋‹ˆ๋‹ค.

MEAL.getMeal(.today).subscribe(onSuccess: { meal in 
   print(meal)
}, onFailure: { err in
   print(err)
})
.disposed(by: disposeBag)
MEAL.getMeal(.anotherDate(date: Date())).subscribe(onSuccess: { meal in
   print(meal)
}, onFailure: { err in
   print(err)
})
.disposed(by: disposeBag)
MEAL.getMeal(.plusMinusDay(day: 0)).subscribe(onSuccess: { meal in
   print(meal)
}, onFailure: { err in
   print(err)
})
.disposed(by: disposeBag)

์•„๋ž˜ ์˜ˆ์ œ๋Š” ์–ด์ œ์˜ ๊ธ‰์‹์ค‘ ์ ์‹ฌ๋งŒ ๊ฐ€์ ธ์˜ค๋Š” ์˜ˆ์ œ์ž…๋‹ˆ๋‹ค.

MEAL.getMeal(.plusMinusDay(day: -1), timePart: .lunch).subscribe(onSuccess: { meal in
   print(meal)
}, onFailure: { err in
   print(err)
})
.disposed(by: disposeBag)

Installation

# Podfile
use_frameworks!

target 'YOUR_TARGET_NAME' do
    pod 'RxSchoolMeal', '1.0.3'
end

Replace YOUR_TARGET_NAME and then, in the Podfile directory, type:

$ pod install

Add this to Cartfile

github "kimxwan0319/RxSchoolMeal" "1.0.3"
$ carthage update
// Package.swift

dependencies: [
    .package(url: "https://github.com/kimxwan0319/RxSchoolMeal", from: "1.0.3")
]

Author

semicolondsmkr, kimxwan0319@naver.com

License

RxSchoolMeal is available under the MIT license. See the LICENSE file for more info.

About

๐Ÿ‡ฐ๐Ÿ‡ท ์ž์‹ ์˜ ํ•™๊ต ๊ธ‰์‹์„ ๊ฐ€์ ธ์˜ฌ ์ˆ˜ ์žˆ๋Š” ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ์ž…๋‹ˆ๋‹ค!

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published