Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add optional label that shows in the object description #50

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

DivineDominion
Copy link
Contributor

Motivation: In my app, I log all actions. This helps with debugging. But sprinkled in now are non-descript log messages like:

💚 11:47:08: > Thunk<AppState>(body: (Function))
💚 11:47:09: > Thunk<AppState>(body: (Function))
💚 11:47:10: > Thunk<AppState>(body: (Function))

With the customizable description, users would be able to see which thunk is being dispatched, e.g.

💚 11:47:08: > Thunk<AppState>(label: "Requesting users")
💚 11:47:09: > Thunk<AppState>(label: "Requesting images for user XYZ")
💚 11:47:09: > Thunk<AppState>(label: "Requesting images for user ABC")

What do y'all think about that?

@dani-mp
Copy link
Collaborator

dani-mp commented Jan 24, 2021

I wonder if this is something that could be done in a custom middleware?

Another reason for this is that thunks are actually fake ReSwift actions, meaning that they can't affect the state in any way. The real actions that happen inside are the ones that should be logged, IMO.

WDYT?

@DivineDominion
Copy link
Contributor Author

So you'd say that logging Thunk dispatching doesn't make sense, and instead one should focus on the actual actions? Hm, I can see how adding log(...) or print statements inside the thunk for debugging purposes to make sense as well. Not sure about the philosophical implications. Logging a useful line instead of "Thunk" would be nice, that's where my argumentation ends :)

@dani-mp
Copy link
Collaborator

dani-mp commented Jan 25, 2021

Yeah, that's my rationale. A thunk is just something that will eventually create real ReSwift actions.

If instead of dispatching a thunk you would implement the async operation directly in the view—for instance, when a user taps a button—, you will expect only the real actions dispatched to be logged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants