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

Change messaging #211

Merged
merged 3 commits into from Jun 7, 2021
Merged

Change messaging #211

merged 3 commits into from Jun 7, 2021

Conversation

Jawnnypoo
Copy link
Member

Seeing the error message cannot call this after evaluation finished. is a little unactionable and hard to tell where it is coming from or what it is referring to unless you look at the source of Formula. So, this should make it a little more clear.

@Jawnnypoo Jawnnypoo requested a review from Laimiux June 7, 2021 17:48
@carrotkite
Copy link

carrotkite commented Jun 7, 2021

JaCoCo Code Coverage 77.75% ✅

Class Covered Meta Status
com/instacart/formula/internal/ScopedCallbacks 86% 0%
com/instacart/formula/internal/FormulaContextImpl 50% 0%

Generated by 🚫 Danger

@Laimiux
Copy link
Collaborator

Laimiux commented Jun 7, 2021

I think these messages are a bit cryptic, however, I don't think including these extra parameters is that useful. It might be better to document common causes of this exception and link to it.

@@ -101,7 +101,7 @@ internal class ScopedCallbacks private constructor(

private fun ensureNotRunning() {
if (!enabled) {
throw java.lang.IllegalStateException("cannot call this callback $currentKey after evaluation finished.")
throw java.lang.IllegalStateException("cannot call this callback after evaluation finished. See https://instacart.github.io/formula/faq/#after-evaluation-finished")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we capitalize cannot?

@@ -42,7 +42,7 @@ class FormulaContextImpl<State> internal constructor(

private fun ensureNotRunning() {
if (transitionCallback.running) {
throw IllegalStateException("cannot call this transition $transitionId after evaluation finished.")
throw IllegalStateException("cannot call this transition after evaluation finished. See https://instacart.github.io/formula/faq/#after-evaluation-finished")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we capitalize cannot?

docs/faq.md Outdated
within the `evaluate` function itself, passing the data you might be using from the `onEvent` into
the `State` defined for that Formula. For example, instead of:
```
class RelatedSearchesFormula @Inject constructor(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The description is perfect, however, I think the example might be a bit too complicated and actually doesn't contain the context.callback usage. I wonder if we could use a simple task example, such as

RxStream.fromObservable { repo.fetchTask(input.taskId) }.onEvent { task ->
  val renderModel = TaskDetailRenderModel(
      title = task.title,
      // Don't do: calling context.callback within "onEvent" will cause a crash described above
      onDeleteSelected = context.callback {
        ...
      }
   )
   transition(state.copy(task = renderModel))
}

@Jawnnypoo
Copy link
Member Author

@Laimiux updated, what do you think?

@Laimiux Laimiux merged commit 00af9ca into master Jun 7, 2021
@Laimiux Laimiux deleted the jawn/change-messaging branch June 7, 2021 21:41
@Laimiux
Copy link
Collaborator

Laimiux commented Jun 7, 2021

@Laimiux updated, what do you think?

Looks great, merged the PR!

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

3 participants