-
Notifications
You must be signed in to change notification settings - Fork 5
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
Add a sponsors page #4
Conversation
handlebarsHelpers.js
Outdated
@@ -43,5 +43,15 @@ module.exports = { | |||
}); | |||
|
|||
return Object.values(speakers); | |||
}, | |||
'getSponsors': function(events) { | |||
const sponsors = {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor
Missing semicolon; 'cos, you know, semicolons are super important 😆
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh the shame! 😞
handlebarsHelpers.js
Outdated
}); | ||
}); | ||
|
||
return Object.values(sponsors); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style
There's nothing wrong with this function but it duplicates the getSpeakers
function differing only in that it is sponsors and not speakers.
I'm okay with the duplication 'cos the algorithm expressed in the functions is straightforward... but we are a tech meetup that's about JS. As such, maybe we should not have such dupes: extracting a shared function that can be called by both is easy enough.
Thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💯 Agree! I'll refactor! :)
}); | ||
}); | ||
return Object.values(deduped); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's nothing wrong here: I'm just sharing.
You may wish to consider using an explicitly curried function here: doing so will lead to less code to write at the places where this dedupe
function is used.
Consider:
// existing way
'getSponsors': function(events) {
return dedupe(events, 'sponsors');
}
// curried way
'getSponsors': dedupe('sponsors')
The latter version is smaller with no loss of clarity: we're deduping the sponsors
. It dispenses with the creation of a "bridging" function that's there just to invoke the dedupe
function.
The latter version is achieved with this small change to the dedupe
function:
const dedupe = key => events => {
const deduped = {};
events && events.forEach(event => {
event[key] && event[key].forEach(item => {
deduped[item.name] = item;
});
});
return Object.values(deduped);
}
I've swapped the order of the arguments around so that events
comes last. I've also transformed the function from a binary one that accepts both key
and events
into a sequence of unary functions. The first unary function takes a key and returns another unary function that takes the events.
The latter point is important because the event handler is looking for a unary function to pass the events to. This refactoring makes it possible to invoke the dedupe
function with the significant bit -- the key
, currently one of sponsors
or speakers
-- and get a function that's ready for invocation by the framework.
Thoughts? It's no biggie, just sharing 😄
Add a page showing all our past an present sponsors.
Wait until #3 is complete so previous sponsors are included.