Changes effect :json/rpc-call to accept on-success and on-error parameters
either as functions OR as re-frame event vectors. The changes are 100% backwards
compatible.
## Why?
Re-frame is very explicit in its documentation and its architecture, saying that
event handlers should be pure. Calling re-frame.core/dispatch in event handlers
makes them sort of stateful.
> So, you can "get away with it". But it ain't pure.
>
> -- https://day8.github.io/re-frame/EffectfulHandlers/#90-solution
In status-mobile, arguably one of our most important effects (not to be confused
with event handlers) is :json-rpc/call, but at the moment, the on-success and
on-error values are expected to be stateful functions (e.g. usually used for
logging and dispatching subsequent events).
This creates two important problems:
1. The value returned by event handlers is more opaque and cannot be easily
inspected (for example using tap>, log/debug or just println). If we try to
inspect or log them, on-success and on-error will be printed as
#object[Function].
2. Testing event handlers using :json-rpc/call becomes an exercise of
frustration, because we can't simply compare the results of the event handler
with a good expected value, which is one of the big selling points of testing
pure functions.
### The testability of event handlers
> For any re-frame app, there's three things to test:
>
> - Event Handlers - most of your testing focus will be here because this is
> where most of the logic lives
> - Subscription Handlers - often not a lot to test here. Only Layer 3
> subscriptions need testing.
> - View functions - I don't tend to write tests for views.
>
> -- https://day8.github.io/re-frame/Testing/#what-to-test
So re-frame is saying event handlers should be pure, and that event handlers
should be tested.
In order to achieve the divine simplicity of testing event handlers as pure
functions, we need to make :json-rpc/call also accept on-success and
on-error as event vectors.
Good news is that there is a known pattern to solve this problem, e.g. used by
the library https://github.com/Day8/re-frame-http-fx.
The pattern is simple once we see it: behind the scenes, :json-rpc/call conj'es
the results of the RPC call into the event vectors on-success and on-error, and
:json-rpc/call dispatches the events itself. This eliminates the need for the
stateful dispatch call in event handlers.
- New section: Use [] instead of () in Reagent components: New section after
this comment https://github.com/status-im/status-mobile/pull/15005#discussion_r1098220176
- Updated section "Don't use percents to define width/height": reworded to
follow the style of the rest of the document.
- Update section "Accessibility labels": added example about avoiding dynamic
labels.
Update certain `style.cljs` files to more strictly follow our guidelines. Except for animations and theme colors, *style* functions should be pure.
It turns out `style` namespaces are well behaved and are almost perfectly following guidelines 🚀
The motivation for the PR came from this thread https://github.com/status-im/status-mobile/pull/14925#discussion_r1090485454
We are trasnferring the Apple app to the new Switzerland based Apple
development organization/team from the old Singapore one, and to make
this work we also need to update the development team ID.
This should fix the following failure:
```
Could not find App ID with bundle identifier 'im.status.ethereum'
You can easily generate a new App ID on the Developer Portal using 'produce':
```
https://ci.infra.status.im/job/status-mobile/job/platforms/job/ios/854/console
Signed-off-by: Jakub Sokołowski <jakub@status.im>
* Update starting guide doc
* Fix bad placement of tut
* formatting and style fixes
Signed-off-by: Jakub Sokołowski <jakub@status.im>
* add adb link
Signed-off-by: Jakub Sokołowski <jakub@status.im>
Co-authored-by: Jakub Sokołowski <jakub@status.im>
Otherwise F-Droid reviewers can merge the PR before we have a final
release version ready with all the fixes included.
Signed-off-by: Jakub Sokołowski <jakub@status.im>
This way the name of the repo makes at least some sense and
matches the `status-desktop` repo naming.
Also updated `status-jenkins-lib` since it also contained
references to `status-react` repo and job names.
Signed-off-by: Jakub Sokołowski <jakub@status.im>
This script fetches a specified APK and analyzes it for values like
version code or commit and then based on that creates a branchy and a
commit in `fdroiddata` repository that can be used to create a release PR.
Signed-off-by: Jakub Sokołowski <jakub@status.im>
Removed superfluous check
Adjusted images to be 50% the page width
Image width 75%
Finished off REPL section
Signed-off-by: Samuel Hawksby-Robinson <samuel@samyoul.com>
Based on https://notes.status.im/9Gr7kqF8SzC_SmYK0eB7uQ?view, hopefully this document can help some poor soul in the future. I have a little more work to do but I'm interested in whether this kind of document would be welcome in the repo