- Install Xcode (Avaliable on the Mac App Store)
- Install Xcode Command Line Tools (Preferences > Downloads)
- Install depot_tools
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
sudo nano ~/.bash_profile
- Add
export PATH=/path/to/depot_tools:"$PATH"
(it's important that depot_tools comes first here)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function scheduleRootUpdate( | |
current: Fiber, | |
element: ReactNodeList, | |
expirationTime: ExpirationTime, | |
suspenseConfig: null | SuspenseConfig, | |
) { | |
const update = createUpdate(expirationTime, suspenseConfig); | |
update.payload = {element}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function updateContainer( | |
element: ReactNodeList, | |
container: OpaqueRoot, | |
parentComponent: ?React$Component<any, any>, | |
callback: ?Function, | |
): ExpirationTime { | |
const current = container.current; | |
const currentTime = requestCurrentTime(); | |
const suspenseConfig = requestCurrentSuspenseConfig(); | |
const expirationTime = computeExpirationForFiber( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function legacyRenderSubtreeIntoContainer( | |
parentComponent: ?React$Component<any, any>, | |
children: ReactNodeList, | |
container: DOMContainer, | |
forceHydrate: boolean, | |
callback: ?Function, | |
) { | |
let root; | |
let fiberRoot; | |
root = container._reactRootContainer = legacyCreateRootFromDOMContainer( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const ReactElement = function(type, key, ref, self, source, owner, props) { | |
const element = { | |
// This tag allows us to uniquely identify this as a React Element | |
$$typeof: REACT_ELEMENT_TYPE, | |
// 内置属性 | |
type: type, | |
key: key, | |
ref: ref, | |
props: props, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function createElement(type, config, children) { | |
let propName; | |
// 这里的type可以是HTML标签字符串,也可以是一个函数,或者一个ReactClass(本质上还是一个函数) | |
// Reserved names are extracted | |
const props = {}; | |
let key = null; | |
let ref = null; | |
let self = null; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function App() { | |
return React.createElement('h1', null, ['Hello World']) | |
} | |
ReactDOM.render(React.createElement(App), document.querySelector('#root')); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
// 直接debug当前文件 | |
"version": "0.2.0", | |
"configurations": [ | |
{ | |
"type": "node", | |
"request": "launch", | |
"name": "Launch Program", | |
"program": "${file}" | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Subscriber 订阅者,持有next,error,complete方法 | |
// Subscribable 可订阅者,持有subscribe方法 | |
// Subscription 订阅,用于绑定关系的模块 持有unsubscribe方法,即取消订阅后的回调逻辑 | |
function pipeFromArray(fns) { | |
if(!fns) return () => {} | |
if(fns.length === 1) return fns[0] | |
return input$ => fns.reduce((prev, fn) => fn(prev), input$) | |
} | |
class Observable { |
NewerOlder