Transducer
Reducer
Reducer 將多個 input fold 成一個 output.
1 | const add = (a, b) => a + b |
Transducer
Transducer 做的事情大致相同,但是與普通的 reducer 不同的是,它可以通過多個 function 組合而成.而普通的 reducer 不能組合,因爲他們接受兩個參數,但是只返回一個值,所以不能將這次的結果傳入下一個 reducer:
1 | // reducer |
Time Picker Pnl
Time Picker Pnl in React Native
Why i write this component?
First, I found a lib called @react-native community/picker and wrote my code based on it. When I was done, it worked fine in ios, but when I turned on my android. Oh, my God, it’s not working. This component is platform based. It behaves differently on different platforms.
Then I found another library called react-native-picker, but it was too ugly and not customizable. My UI designer wouldn’t let me use this kind of thing, so I wrote my own component.
Note: This component is not perfect, but it works fine in my work. If you have any suggestion or issue, please let me know. You can build your own component based on this code.
If this code help you, please follow me on Github. XD(am greedy)
Requirements:
react-native-modal: pop up modal for time picker

TypeScript Generics
Generics
1 | function foo<T>(arg: T): T { |
Generics Types
1 | function foo<T>(arg: T): T { |
TypeScript Functions
Function Types
Typing the function
1 | function foo(x: number, y: string): string { |
Writing the function type
1 | let foo: (x: number, y: string) => string = function ( |
Inferring types
1 | let foo: (x: number, y: string) => string = function (x, y) { |