Skip to content

Commit ba0507b

Browse files
committed
feat(demo): update angular standalone
1 parent fbe5b18 commit ba0507b

43 files changed

Lines changed: 9136 additions & 6949 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.cursor/rules/angular-default.mdc

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
---
2+
alwaysApply: true
3+
---
4+
5+
You are an expert in TypeScript, Angular, and scalable web application development. You write maintainable, performant, and accessible code following Angular and TypeScript best practices.
6+
7+
## TypeScript Best Practices
8+
9+
- Use strict type checking
10+
- Prefer type inference when the type is obvious
11+
- Avoid the `any` type; use `unknown` when type is uncertain
12+
13+
## Angular Best Practices
14+
15+
- Always use standalone components over NgModules
16+
- Must NOT set `standalone: true` inside Angular decorators. It's the default.
17+
- Use signals for state management
18+
- Implement lazy loading for feature routes
19+
- Do NOT use the `@HostBinding` and `@HostListener` decorators. Put host bindings inside the `host` object of the `@Component` or `@Directive` decorator instead
20+
- Use `NgOptimizedImage` for all static images.
21+
- `NgOptimizedImage` does not work for inline base64 images.
22+
23+
## Components
24+
25+
- Keep components small and focused on a single responsibility
26+
- Use `input()` and `output()` functions instead of decorators
27+
- Use `computed()` for derived state
28+
- Set `changeDetection: ChangeDetectionStrategy.OnPush` in `@Component` decorator
29+
- Prefer inline templates for small components
30+
- Prefer Reactive forms instead of Template-driven ones
31+
- Do NOT use `ngClass`, use `class` bindings instead
32+
- Do NOT use `ngStyle`, use `style` bindings instead
33+
34+
## State Management
35+
36+
- Use signals for local component state
37+
- Use `computed()` for derived state
38+
- Keep state transformations pure and predictable
39+
- Do NOT use `mutate` on signals, use `update` or `set` instead
40+
41+
## Templates
42+
43+
- Keep templates simple and avoid complex logic
44+
- Use native control flow (`@if`, `@for`, `@switch`) instead of `*ngIf`, `*ngFor`, `*ngSwitch`
45+
- Use the async pipe to handle observables
46+
47+
## Services
48+
49+
- Design services around a single responsibility
50+
- Use the `providedIn: 'root'` option for singleton services
51+
- Use the `inject()` function instead of constructor injection

android/src/main/java/com/getcapacitor/community/admob/consent/AdConsentExecutor.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public void requestConsentInfo(final PluginCall call, BiConsumer<String, JSObjec
7171
consentInfo.put("privacyOptionsRequirementStatus", consentInformation.getPrivacyOptionsRequirementStatus().name());
7272
call.resolve(consentInfo);
7373
},
74-
formError -> call.reject(formError.getMessage())
74+
(formError) -> call.reject(formError.getMessage())
7575
);
7676
} catch (Exception ex) {
7777
call.reject(ex.getLocalizedMessage(), ex);
@@ -88,7 +88,7 @@ public void showPrivacyOptionsForm(final PluginCall call, BiConsumer<String, JSO
8888
}
8989
ensureConsentInfo();
9090
activity.runOnUiThread(() ->
91-
UserMessagingPlatform.showPrivacyOptionsForm(activity, formError -> {
91+
UserMessagingPlatform.showPrivacyOptionsForm(activity, (formError) -> {
9292
if (formError != null) {
9393
call.reject("Error when show privacy form", formError.getMessage());
9494
} else {
@@ -112,7 +112,7 @@ public void showConsentForm(final PluginCall call, BiConsumer<String, JSObject>
112112

113113
ensureConsentInfo();
114114
activity.runOnUiThread(() ->
115-
UserMessagingPlatform.loadAndShowConsentFormIfRequired(activity, formError -> {
115+
UserMessagingPlatform.loadAndShowConsentFormIfRequired(activity, (formError) -> {
116116
if (formError != null) {
117117
call.reject("Error when show consent form", formError.getMessage());
118118
return;

android/src/test/java/com/getcapacitor/community/admob/consent/AdConsentExecutorTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ void beforeEach() {
6262

6363
adConsentExecutor = new AdConsentExecutor(() -> contextMock, () -> activityMock, notifierMock, LOG_TAG);
6464

65-
doAnswer(invocation -> {
65+
doAnswer((invocation) -> {
6666
Runnable runnable = invocation.getArgument(0);
6767
runnable.run();
6868
return null;

android/src/test/java/com/getcapacitor/community/admob/interstitial/AdInterstitialExecutorTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,8 @@ void usesIdHelper() {
146146
Runnable uiThreadRunnable = runnableArgumentCaptor.getValue();
147147
uiThreadRunnable.run();
148148

149-
interstitialAdMockedStatic.verify(() -> InterstitialAd.load(any(), idArgumentCaptor.capture(), adRequestCaptor.capture(), any())
149+
interstitialAdMockedStatic.verify(() ->
150+
InterstitialAd.load(any(), idArgumentCaptor.capture(), adRequestCaptor.capture(), any())
150151
);
151152

152153
assertEquals(idFromViewHelper, idArgumentCaptor.getValue());

demo/angular/.eslintrc.json

Lines changed: 0 additions & 51 deletions
This file was deleted.

0 commit comments

Comments
 (0)