loading...

re: 5 Programming Patterns I Like VIEW POST

TOP OF THREAD FULL DISCUSSION
re: Example with no object creation in the function: // Object literal const createContent = function(contentType){ const contentTypes = createCon...
 

I love this solution, very simple;

I usually do this:

const  fromTypes = (types, def = null) => type => (types[type] || def)

const createContent = fromTypes({ post: Post, video: Video }, Unknown)

createContent('post')

This is how redux architecture works ;)

code of conduct - report abuse