Upgrade to Pro — share decks privately, control downloads, hide ads and more …

iOS and Android Application with React-Native-L...

laprasDrum
December 07, 2017

iOS and Android Application with React-Native-Layered Domain Model

laprasDrum

December 07, 2017
Tweet

More Decks by laprasDrum

Other Decks in Technology

Transcript

  1. Nullable Property ͳΒ໰୊ͳ͠ export default class App extends Component<{}> {

    componentDidMount() { let adapter = NativeModules.RLDRootAdapter; let languages = [ { type: "Swift", stars: 41872 }, { type: "Kotlin" }, <————— ] adapter.emitChange(languages); } render() { return <View />; } } import Foundation struct Language: Codable { var type: String = "" var stars: Int? = 0 <————— }
  2. NonNull Property ͳΒ Runtime Ͱؾ෇͚ΔΑ͏ʹ export default class App extends

    Component<{}> { componentDidMount() { let adapter = NativeModules.RLDRootAdapter; let languages = [ { type: "Swift", stars: 41872 }, { type: "Kotlin" }, <————— ] adapter.emitChange(languages); } render() { return <View />; } } import Foundation struct Language: Codable { var type: String = "" var stars: Int = 0 <————— }
  3. Android ͩͱʁ Codable Ͱอূ͔ͨͬͨ͜͠ͱ͸ square/moshi Ͱ୲อͰ͖ͦ͏ data class Language( val

    type: String, val stars: Int ) val json = """ {"type": “swift"} """ val moshi = Moshi.Builder() .add(KotlinJsonAdapterFactory()) .build() // throw JsonDataException val lang = moshi.adapter(Language::class.java).fromJson(json)
  4. ࠓޙͷݕূ࣮ݧ Android ઈࢍରԠத ͋ΘΑ͘͹ API ୟ͘ͱ͜΋ React Native ଆʹدͤΔͷ΋͋Γ͔΋ͱࢥͬͯΔ →

    Data Layer ͱͯ͠·ͱΊΔͱΑ͔͛͞ݕূ Models ViewModel View Web Resources ਖ਼௚ React Native ͡Όͳͯ͘Α͘Ͷʁ ͱ͍͏ؾ࣋ͪ͸͋Δ ʢ͋·Γָʹͳͬͨײ͕ͳ͍͠ɺRepo ෼ׂͲ͏͢ΔΑʣ