Skip to content

Commit 3d6e5ed

Browse files
committed
feat(design): add observer pattern to design package
1 parent 8f7f066 commit 3d6e5ed

33 files changed

+567
-45
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,4 @@ Thumbs.db
4040

4141
.nx/cache
4242
.angular
43+
.env

CODE_OF_CONDUCT.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,20 @@ appearance, race, religion, or sexual identity and orientation.
1414
Examples of behavior that contributes to creating a positive environment
1515
include:
1616

17-
* Use welcoming and inclusive language
18-
* Respect each other
19-
* Provide and gracefully accept constructive criticism
20-
* Show empathy towards other community members
17+
- Use welcoming and inclusive language
18+
- Respect each other
19+
- Provide and gracefully accept constructive criticism
20+
- Show empathy towards other community members
2121

2222
Examples of unacceptable behavior by participants include:
2323

24-
* Trolling, insulting/derogatory comments, and personal or political attacks
25-
* Public or private harassment
26-
* Publishing others' private information, such as a physical or electronic
24+
- Trolling, insulting/derogatory comments, and personal or political attacks
25+
- Public or private harassment
26+
- Publishing others' private information, such as a physical or electronic
2727
address, without explicit permission
28-
* The use of sexualized language or imagery
29-
* Unwelcome sexual attention or advances
30-
* Other conduct which could reasonably be considered inappropriate in a
28+
- The use of sexualized language or imagery
29+
- Unwelcome sexual attention or advances
30+
- Other conduct which could reasonably be considered inappropriate in a
3131
professional setting
3232

3333
## Our Responsibilities
@@ -69,9 +69,9 @@ members of the project's leadership.
6969

7070
If you are banned you may contest the decision. To do so email [email protected] with the subject line "Repeal Ban for {{your name here}}" and body with the responses to the following:
7171

72-
* Why do you believe you did not violate the Code of Conduct?
73-
* Were other factors involved in this situation the leadership team may have been unaware of?
74-
* Why do you wish to be a part of the Angular community?
72+
- Why do you believe you did not violate the Code of Conduct?
73+
- Were other factors involved in this situation the leadership team may have been unaware of?
74+
- Why do you wish to be a part of the Angular community?
7575

7676
## Attribution
7777

nx.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
"style": "scss"
6767
},
6868
"@nxgs/design": {
69-
"lang": "pt-br"
69+
"lang": "en-us"
7070
}
7171
}
7272
}

packages/design/src/constants/i18n/en-us/behavioral.command.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { BehavioralCommand } from '../interfaces';
22

3-
export const behavioralCommand: BehavioralCommand = {
3+
const behavioralCommand: BehavioralCommand = {
44
command: `The Command interface declares a method for executing a command.`,
55

66
simpleCommand: `Some commands can implement simple operations on their own.`,
@@ -36,3 +36,5 @@ export const behavioralCommand: BehavioralCommand = {
3636

3737
alsoWorkingOn: `Also working on`,
3838
};
39+
40+
export default behavioralCommand;
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { BehavioralObserver } from '../interfaces';
2+
3+
const behavioralObserver: BehavioralObserver = {
4+
subject: `The Subject interface declares a set of methods for managing subscribers.`,
5+
subjectSubscribe: `Attach an observer to the subject.`,
6+
subjectUnsubscribe: `Detach an observer from the subject.`,
7+
subjectNotify: `Notify all observers about an event.`,
8+
concreteSubject: `The Subject owns some important state and notifies observers when the state
9+
* changes.`,
10+
concreteSubjectState: `For the sake of simplicity, the Subject's state, essential
11+
* to all subscribers, is stored in this variable.`,
12+
concreteSubjectObservers: `List of subscribers. In real life, the list of
13+
* subscribers can be stored more comprehensively (categorized by event
14+
* type, etc.).`,
15+
concreteSubjectSubscribe: `The subscription management methods.`,
16+
concreteSubjectUnsubscribe: ``,
17+
concreteSubjectNotify: `Trigger an update in each subscriber.`,
18+
observer: `The Observer interface declares the update method, used by subjects.`,
19+
observerUpdate: `Receive update from subject.`,
20+
concreteObserverA: `Observers react to the updates issued by the Subject they had been
21+
* attached to.`,
22+
concreteObserverUpdate: `Reacted to the event.`,
23+
concreteSubjectSomeBusinessLogic: `Usually, the subscription logic is only a fraction of what a Subject can
24+
* really do. Subjects commonly hold some important business logic, that
25+
* triggers a notification method whenever something important is about to
26+
* happen (or after it).`,
27+
};
28+
29+
export default behavioralObserver;

packages/design/src/constants/i18n/interfaces/behavioral-command.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,23 @@ export interface BehavioralCommand {
1414
workingOn: string;
1515
alsoWorkingOn: string;
1616
}
17+
18+
export interface BehavioralObserver {
19+
subject: string;
20+
subjectSubscribe: string;
21+
subjectUnsubscribe: string;
22+
subjectNotify: string;
23+
24+
concreteSubject: string;
25+
concreteSubjectState: string;
26+
concreteSubjectObservers: string;
27+
concreteSubjectSubscribe: string;
28+
concreteSubjectUnsubscribe: string;
29+
concreteSubjectNotify: string;
30+
concreteSubjectSomeBusinessLogic: string;
31+
32+
observer: string;
33+
observerUpdate: string;
34+
concreteObserverA: string;
35+
concreteObserverUpdate: string;
36+
}

packages/design/src/constants/i18n/pt-br/behavioral.command.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { BehavioralCommand } from '../interfaces';
22

3-
export const behavioralCommand: BehavioralCommand = {
3+
const behavioralCommand: BehavioralCommand = {
44
command: `A interface Command declara um método para executar um command.`,
55

66
simpleCommand: `Alguns commands podem implementar operações simples por conta própria.`,
@@ -36,3 +36,5 @@ export const behavioralCommand: BehavioralCommand = {
3636

3737
alsoWorkingOn: `Também trabalhando em`,
3838
};
39+
40+
export default behavioralCommand;
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { BehavioralObserver } from '../interfaces';
2+
3+
const behavioralObserver: BehavioralObserver = {
4+
subject: `A interface Subject declara um conjunto de métodos para gerenciar assinantes.`,
5+
subjectSubscribe: `Adicione um observador ao assunto.`,
6+
subjectUnsubscribe: `Remova um observador do assunto.`,
7+
subjectNotify: `Notifique todos os observadores sobre um evento.`,
8+
concreteSubject: `O Sujeito possui algum estado importante e notifica os observadores quando o estado
9+
* muda.`,
10+
concreteSubjectState: `Por uma questão de simplicidade, o estado do Assunto, essencial
11+
* para todos os assinantes, é armazenado nesta variável.`,
12+
concreteSubjectObservers: `Lista de assinantes. Na vida real, a lista de
13+
* assinantes pode ser armazenada de forma mais abrangente (categorizada por
14+
* tipo de evento, etc.).`,
15+
concreteSubjectSubscribe: `Os métodos de gerenciamento de assinaturas.`,
16+
concreteSubjectUnsubscribe: ``,
17+
concreteSubjectNotify: `Notifique uma atualização em cada assinante.`,
18+
observer: `A interface Observer declara o método update, utilizado pelos sujeitos.`,
19+
observerUpdate: `Receba atualização do assunto.`,
20+
concreteObserverA: `Os Observadores reagem às atualizações emitidas pelo Assunto ao qual
21+
* foram anexados.`,
22+
concreteObserverUpdate: `Reagiu ao evento.`,
23+
concreteSubjectSomeBusinessLogic: `Normalmente, a lógica da assinatura é apenas uma fração do que um Assunto
24+
* pode realmente fazer. Os assuntos geralmente possuem alguma lógica de negócios importante,
25+
* que aciona um método de notificação sempre que algo importante está para
26+
* acontecer (ou depois disso).`,
27+
};
28+
29+
export default behavioralObserver;

0 commit comments

Comments
 (0)