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

Introducing Function Builder

100059
December 17, 2019

Introducing Function Builder

potatotips #267
2019/12/17

100059

December 17, 2019
Tweet

More Decks by 100059

Other Decks in Technology

Transcript

  1. Introducing Function Builder potatotips #267 2019/12/17

  2. Akihisa Sengoku @akihisasen גࣜձࣾαΠόʔΤʔδΣϯτ AmebaʢΞϝʔόʣ iOSΤϯδχΞ

  3. Function Builderͱ͸ʁ

  4. 4XJGU6*Ͱ࢖ΘΕ͍ͯΔΫϩʔδϟʔతͳ΋ͷʁ

  5. %4-Λॻ͘͜ͱ͕Ͱ͖ΔΑ͏ʹͳͬͨʁ

  6. 4XJGUͰ௥Ճ͞Εͨ৽ػೳ 1SPQPTBM 'PSVN

  7. Builderͷϧʔϧʹैͬͯؔ਺Λ ҉໧తʹม׵͢Δ͜ͱ͕Ͱ͖Δ #VJMEFSΛ దԠͨؔ͠਺ #VJMEFSϧʔϧʹ Ԡͯؔ͡਺Λม׵ #VJMEFSΛఆٛ #VJMEFSΛ దԠ

  8. None
  9. None
  10. Function BuilderʹΑΓ ಠࣗͷDSLΛΑΓ࡞੒͠΍͘͢ͳͬͨ - Structure Data (json, XML) - UI

    View Hierarchies - HTML DOM Hierarchies
  11. ࡞Γํ!

  12. #VJMEFSͷ࡞੒ํ๏ʹ͍ͭͯ

  13. Builderͷ࡞੒ํ๏ 1. struct or classͷલʹ`@_functionBuilder`Λ͚ͭͯ ఆٛ͢Δɻ 2. static func Ͱ

    `buildBlock(_ components: Component...) -> Component` Λఆٛ͢Δɻ
  14. ͦͷଞͷbuildͷ࣮૷ • buildExpression(_ expression: Expression) -> Component • buildFunction(_ components:

    Component...) - > Return • buildDo(_ components: Component...) -> Component • buildOptional(_ component: Component?) -> Component
  15. 'VODUJPO#VJMEFSͷ࢖༻ํ๏

  16. Function Builderͷ࢖༻ํ๏ 1. Function BuilderΛ࢖༻͍ͨؔ͠਺ͷલʹ @FunctionBuilder໊Λ͚ͭΔ 2. BuilderͷbuildBlockʹରԠ͢ΔҾ਺Λɺ վߦ۠੾ΓͰهड़

  17. ؔ਺ͷҾ਺ͷΫϩʔδϟͰFunction Builder Λ࢖༻͢Δ͜ͱ͕Ͱ͖Δ

  18. None
  19. ϓϩμΫτಋೖ

  20. SwiftUI HTML NSAttributedString Network UIKit ϓϩμΫτಋೖ: DSL

  21. Amebaͷಋೖྫ NSAttributedStringͷIFΛ៉ྷʹ   5JQT

  22. What's New in Swift - WWDC2019 https://developer.apple.com/videos/play/ wwdc2019/402/ Function Builder

    - swift-evolution https://github.com/apple/swift-evolution/blob/ 9992cf3c11c2d5e0ea20bee98657d93902d5b17 4/proposals/XXXX-function-builders.md