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

Using Hooks in iOS App Development - CA.swift #14

Using Hooks in iOS App Development - CA.swift #14

Using Hooks in iOS App Development - CA.swift #14

Takuma Osada

May 19, 2021
Tweet

More Decks by Takuma Osada

Other Decks in Technology

Transcript

  1.   Agenda 1. Simple Conclusion 2. What’s Hooks? 3.

    Introduction of Hooks API 4. Advantages & Drawbacks 5. Final Conclusion
  2.   What’s Hooks? Hooks are a new addition in

    React 16.8. (Feb 2019) They let you use state and other React features without writing a class. React Hooks API Reference
  3.   What’s Hooks? YouTube: React Today and Tomorrow and

    90% Cleaner with React Hooks 🔥 Wrapper Hell 📦 Huge Components 😓 Confusing Classes Hooks Solves...
  4.   What’s Hooks? Hooks also used in Flutter as

    well rrousselGit/flutter_hooks
  5.   Introduction of Hooks API ・useState ・useEffect ・useLayoutEffect ・useMemo

    ・useRef ・useReducer ・useEnvironment ・usePublisher ・usePublisherSubscribe ・useContext
  6.   Introduction of Hooks API ・useState ・useEffect ・useLayoutEffect ・useMemo

    ・useRef ・useReducer ・useEnvironment ・usePublisher ・usePublisherSubscribe ・useContext
  7.   Introduction of Hooks API useState A hook to

    use a Binding<State> wrapping current state to be updated by setting a new state to wrappedValue. Triggers a view update when the state has been changed.
  8.   Introduction of Hooks API useEffect A hook to

    use a side effect function that is called the number of times according to the strategy specified by computation. Optionally the function can be cancelled when this hook is unmount from the view tree or when the side-effect function is called again. Note that the execution is deferred until after all the hooks have been evaluated.
  9.   Introduction of Hooks API useRef A hook to

    use a mutable ref object storing an arbitrary value. The essential of this hook is that setting a value to current doesn't trigger a view update.
  10.   Introduction of Hooks API usePublisher A hook to

    use the most recent status of asynchronous operation of the passed publisher. The publisher will be subscribed at the first computation and will be re-subscribed according to the strategy specified with the passed computation. Triggers a view update when the asynchronous status has been changed.
  11.   Advantages & Drawbacks Advantages ✔ Less Codes, Less

    Classes & Struct ✔ Linter works on Top Level Codings ✔ Enable to use Minimum & Partial
  12.   Advantages & Drawbacks Drawbacks ✖ Very few Documents

    & Samples ✖ More cost for Learnings ✖ Compared with React & Flutter, Insufficient Conclusive to use ✖ Existence of The Composable Architecture
  13.   Final Conclusion Not 👎 but also not 😆

    ↓ Lots of benefits using Hooks in React & Flutter. How about using in SwiftUI...?