Decorator

Alias Decorator pattern (Wrapper). Definition Decoration is a structural design pattern that allows you to bind new behaviors to an original object by placing it in a special encapsulating object that contains the behavior. Foreword 1. Question Suppose you are developing a library that provides notification functionality that other programs can use to notify users […]

Design thinking cultivation: RecyclerView in decorator mode adds head and tail

Use a design pattern to cultivate high reuse and low coupling ideas Preface Decorators in Android Code Step 1: Create the decorator DecorateAdapter Step 2: Process the binding relationship between the header, middle content, and tail Step 3: Use of decorators Step 4: Improve and directly encapsulate a View Summarize Foreword A code with high […]

A brief analysis of Python decorators

Implement interception of attribute editing operations In the last chapter, we talked about using class-based descriptors and function decorators in Python to implement interception operations for object attribute access. Then we can easily think that since we can intercept the access operation to the attribute, we must also be able to intercept the editing operation […]

Using vue-property-decorator in vue

1. Foreword Vue.js is a very popular front-end framework that can quickly build interactive single-page applications. vue-property-decorator is a decorator library for Vue.js that can help us write Vue.js components more conveniently. Let’s explain in detail the usage of vue-property-decorator. vue-class-component is the official library of vue. Its function is to write components in the […]

Decorator Pattern

1. Mode motivation Decorator Pattern is a technology used to replace inheritance. It dynamically adds responsibilities to objects in a way that does not require defining subclasses. Replace inheritance relationships between classeswith associations between objects. In the decoration mode, the decoration class is introduced. In the decoration class, you can not only call the methods […]

vue-property-decorator source code analysis

Foreword When using vue-class-components to build Vue components, attributes such as watch and props still need to be written in @Component in. @Component({<!– –> watch: {<!– –> postId(id: string) {<!– –> // To fetch post data when the id is changed. this.fetchPost(id) // -> Property ‘fetchPost’ does not exist on type ‘Vue’. }, }, }) […]

Decorator mode (Decorator)

alias Decorator mode (Wrapper). Define Decoration is a structural design pattern that allows you to bind new behavior to an object by placing it in a special wrapper object that contains the behavior. Foreword 1. Question Suppose you are developing a library that provides notification functionality that other programs can use to notify users of […]

Decorator mode (11)

Please believe in yourself, please believe in yourself again, please believe in yourself The previous chapter briefly introduced the bridge mode (10), if you haven’t read it, please watch the previous chapter 1. Decorator mode Refer to the introduction to the decorator pattern in the rookie tutorial: https://www.runoob.com/design-pattern/decorator-pattern.html The Decorator Pattern allows adding new functionality […]

Vue2 combined with tsx related writing in vue-property-decorator

Basic writing import {<!– –> Component, Prop, Vue } from ‘vue-property-decorator’ @Component export default class TsxVue extends Vue {<!– –> render(h, hack) {<!– –> return <div>Test tsx</div> } } Prop writing method import {<!– –> Component, Prop, Vue } from ‘vue-property-decorator’ @Component export default class TsxVue extends Vue {<!– –> @Prop() text!: string @Prop({<!– –> […]

electron-ipc-decorators: Let your Electron desktop application main process and rendering process communicate easily and wonderfully

Article directory foreword 1. What is it? in the rendering process in the main process 2. Use steps The class diagram is as follows code show as below 3. Implementation details rendering process main process Summarize Foreword If you are an Electron web desktop developer and want to simplify IPC communication development, it is recommended […]