-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathindex.js.map
1 lines (1 loc) · 3.78 KB
/
index.js.map
1
{"version":3,"file":"index.js","sources":["src/index.js"],"sourcesContent":["import { createElement, Component, Children } from 'react'\n\nconst CONTEXT_TYPES = {\n store: () => {}\n}\n\nexport class Provider extends Component {\n getChildContext() {\n return { store: this.props.store }\n }\n\n render() {\n return Children.only(this.props.children)\n }\n}\n\nProvider.childContextTypes = CONTEXT_TYPES\n\nexport const connect = (...args) => {\n const Comp = args.slice(-1)[0]\n const strings = args.length > 1 ? args.slice(0, -1) : []\n const actionCreators = []\n const keysToWatch = []\n strings.forEach(str => {\n if (str.slice(0, 6) === 'select') {\n keysToWatch.push(str)\n return\n }\n if (str.slice(0, 2) === 'do') {\n actionCreators.push(str)\n return\n }\n throw Error(`CanNotConnect ${str}`)\n })\n\n class Connect extends Component {\n constructor(props, context) {\n super(props, context)\n const store = context.store\n this.state = store.select(keysToWatch)\n this.unsubscribe = store.subscribeToSelectors(\n keysToWatch,\n this.setState.bind(this)\n )\n this.actionCreators = {}\n actionCreators.forEach(name => {\n this.actionCreators[name] = (...args) => {\n if (store.action) {\n return store.action(name, args)\n }\n return store[name](...args)\n }\n })\n }\n\n componentWillUnmount() {\n this.unsubscribe()\n }\n\n render() {\n return createElement(\n Comp,\n Object.assign({}, this.props, this.state, this.actionCreators)\n )\n }\n }\n Connect.contextTypes = CONTEXT_TYPES\n Connect.displayName = 'connect(' + (Comp.displayName || Comp.name) + ')'\n return Connect\n}\n"],"names":["const","CONTEXT_TYPES","store","Provider","getChildContext","props","render","Children","only","children","Component","childContextTypes","connect","Comp","args","slice","strings","length","actionCreators","keysToWatch","forEach","str","push","Error","Connect","constructor","context","state","select","unsubscribe","subscribeToSelectors","setState","bind","name","action","componentWillUnmount","createElement","Object","assign","contextTypes","displayName"],"mappings":";;AAEAA,IAAMC,aAAa,GAAG;EACpBC,KAAK,cAAQ;CADf;AAIA,IAAaC,QAAN;;;;;;;;;qBAC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