Skip to content

Instantly share code, notes, and snippets.

View gabrielmlinassi's full-sized avatar
🏠
Working from home

Gabriel Marmitt gabrielmlinassi

🏠
Working from home
View GitHub Profile
@gabrielmlinassi
gabrielmlinassi / async-try-catch-snippet-03.js
Last active May 8, 2021 14:50 — forked from jmaicaaan/try-catch-snippet-03.js
[Tutorial] Functional try catch
const asyncTryCatch = async (tryer) => {
try {
const data = await tryer();
return [data, null];
} catch (error) {
return [null, error];
}
};
export default async function (req: NextApiRequest, res: NextApiResponse) {
@gabrielmlinassi
gabrielmlinassi / fp.js
Created July 4, 2020 12:46 — forked from BretCameron/fp.js
An example of functional programming in JavaScript, featuring compose, pipe, tap and trace functions
/**
* Performs right-to-left composition, combining multiple functions into a single function.
* @function compose
* @param {...Function} args
* @returns {Function}
*/
const compose = (...fns) => x => fns.reduceRight((output, fn) => fn(output), x, fns);
/**
* Performs left-to-right composition, combining multiple functions into a single function. Sometimes called `sequence`. Right-to-left composition is typically known as `compose`.

#Understanding MVC And MVP (For JavaScript & Backbone Developers)

Before exploring any JavaScript frameworks that assist in structuring applications, it can be useful to gain a basic understanding of architectural design patterns. Design patterns are proven solutions to common development problems and can suggest structural paradigms to help guide us in adding some organization to our application.

I think patterns are exciting as they're effectively a grass roots effort that build upon the collective experience of skilled developers who have previously faced similar problems as we do now. Although developers 10 or 20 years ago may not have been using the same programming languages for implementing patterns, there are many lessons we can learn from their efforts.

In this section, we're going to review two popular patterns - MVC and MVP. The context of our exploration will be how these patterns are related to the popular JavaScript framework Backbone.js, which will be explored in greater detail later on.