Skip to content

Instantly share code, notes, and snippets.

View pabletecodes's full-sized avatar

Pablo Alonso pabletecodes

View GitHub Profile
@pabletecodes
pabletecodes / design-challenge-002-0-before.js
Last active June 7, 2024 11:25
Design Challenge 002: Simplifying State Management in React
// Design Challenge 002: Simplifying State Management in React
// https://juntao.substack.com/p/design-challenge-002-simplifying
const ApprovalPanel = ({id}) => {
const [isDone, setDone] = useState(false);
const handleApprove = () => {
fetch('POST', `/rest/approval/${id}/approve`)
.then(r => r.json())
.then(data => setDone(data.isDone));
@pabletecodes
pabletecodes / 0-before.js
Last active June 25, 2024 07:48
Encapsulating collections in JavaScript 🎁
class Team {
constructor(members) {
this._members = members;
}
get members() {
return this._members;
}
set members(members) {
@pabletecodes
pabletecodes / design-challenge-003-0-before.js
Last active June 29, 2024 16:03
Design Challenge 003: Generating Context Menu from Legacy API Response
// Your challenge is to find ways to simplify this code further.
// You can use any patterns or refactoring techniques you find useful.
// Think about improving readability and maintainability while ensuring the
// functionality remains intact.
// Backend response
{
"operations": [
{