Tech Tim Profile picture
❤️Learn, Share and Grow 💻Software Engineer | AWS Professional | Open Source Lover ☘️Passionate about Dev Experience Improvement

Jul 21, 2022, 8 tweets

Learn JS Patterns - 1 Singleton
- harder to write unit test for app
- consider #Redux as a (kind of) singleton
- a bit breaks Single Responsibility Principle, because it solves two problems (keep one instance for a class, assign a global access point to the instance)
@keurplkar

@keurplkar Learn JS Patterns - 2 Proxy Pattern

- Proxy can help on validating, formatting, notification, debugging etc
- It add control over the behavior of an object, so over using Proxy may grant performance issue

@lydiahallie

@keurplkar 3 Provider Pattern

- Very common in React, make data accessible to multiple child components to avoid props drilling
- For example #mui theme provider

@keurplkar 4 Prototype
For example
dog1.prototype.bark='wow'

The prototype pattern is a useful way to share properties among many objects of the same type.

Careful, avoid #prototype pollution

@keurplkar 5 Container/Presentation

- use container to fetch data and wrap presentation component
- use presentation component to show UI

But actually, to use hooks may be better in React application

@keurplkar 6 Observer

we can use the observer pattern in many ways, it can be very useful when working with **asynchronous, event-based** data.

- Good to implement single-responsiblity principle
- If an observer becomes too complex, may cause performance issues

Share this Scrolly Tale with your friends.

A Scrolly Tale is a new way to read Twitter threads with a more visually immersive experience.
Discover more beautiful Scrolly Tales like this.

Keep scrolling