Rules Hub
Coding Rules Library
← Back to all rules
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
frontend ruleP2universalStack: javascript
rxjsstreamsfunctionalreadability
Express conditional handling as a stream operator, not a nested if
When working with observable streams, model a condition as a filter/operator in the pipeline rather than wrapping the subscriber body in an if.
PR: frontpage-web · org-mining-hist-2026-06Created: Jun 18, 2026
Bad example
Old codetypescript
| 1 | stream.subscribe(v => { |
| 2 | if (v.length > 2) doSearch(v); |
| 3 | }); |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | stream.pipe(filter(v => v.length > 2)).subscribe(doSearch); |
Explanation (EN)
Objašnjenje (HR)