Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding a forced generator option #1131

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions node_package/src/ComponentRegistry.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ const registeredComponents = new Map();
export default {
/**
* @param components { component1: component1, component2: component2, etc. }
* @param componentsAreGeneratorFunctions boolean
*/
register(components) {
register(components, componentsAreGeneratorFunctions) {
Object.keys(components).forEach(name => {
if (registeredComponents.has(name)) {
console.warn('Called register for component that is already registered', name);
Expand All @@ -19,7 +20,7 @@ export default {
throw new Error(`Called register with null component named ${name}`);
}

const isGeneratorFunction = generatorFunction(component);
const isGeneratorFunction = componentsAreGeneratorFunctions || generatorFunction(component);
const isRenderer = isGeneratorFunction && component.length === 3;

registeredComponents.set(name, {
Expand Down
4 changes: 2 additions & 2 deletions node_package/src/ReactOnRails.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ ctx.ReactOnRails = {
* find you components for rendering.
* @param components (key is component name, value is component)
*/
register(components) {
ComponentRegistry.register(components);
register(components, componentsAreGeneratorFunctions) {
ComponentRegistry.register(components, componentsAreGeneratorFunctions);
},

/**
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"scripts": {
"test": "babel-tape-runner -r node_package/tests/helpers/test_helper.js node_package/tests/*.js | tap-spec",
"clean": "rm -rf node_package/lib",
"prepare": "yarn run build",
"prepare": "npm run babel",
"prepublish": "npm run prepare",
"babel": "babel --out-dir node_package/lib node_package/src",
"build": "yarn run clean && yarn run babel",
Expand Down