question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add 'event' parameter to 'handled' lambda in 'ViewEvent' 'peek()'

See original GitHub issue

This is not an important change, but It’s an enhancement. Currently, the function peek, It’s the following:

viewModel.observeState(this) {
    it.event?.peek {
        when (it.event) {
            is CatViewEvent.Meow -> {
                // show Meow! dialog
                true
            }
        }
    }
}

But into the peek function, I need use again the “it.event”. It’s can resolve changing the parameter in the peek function:

fun peek(handled: ViewEvent.() -> Boolean) {
    if (!alreadyHandled) alreadyHandled = this.handled()
}

So, the new peek method would be used:

viewModel.observeState(this) {
    it.event?.peek {
        when (this) {
            is CatViewEvent.Meow -> {
                // show Meow! dialog
                true
            }
        }
    }
}

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
etiennelenhartcommented, Oct 8, 2018

Normally executing an event multiple times should be accomplished by setting an updated ViewState with a new event.

I totally forgot about internal. That should accomplish pretty much exactly what I’m aiming for. I’ll probably keep this for a later update though since it’s a really minor thing.

Thanks for your input. 🙂

1reaction
eugenio1590commented, Oct 8, 2018

Hi @etiennelenhart , I apologize for the delay. Thanks for the support. I was thinking about it too and I think that the public variable would help to execute events again. Similarly, the visibility “internal” would help a lot. Thanks again for the support, I will be testing as soon as possible.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Lambda event source mappings - AWS Documentation
Configure a Lambda event source mapping to invoke your function from queue and stream event sources, such as Amazon SQS, Kinesis, and DynamoDB....
Read more >
Chapter 2: What is the event & context?
When you create a lambda function from the console, it is automatically populated ... Handler functions must always take two arguments, event and...
Read more >
Integrating Lambda Expressions and Events
Using lambda expressions is a more compact way of wiring up events in both C# and Visual Basic. It also provides a way...
Read more >
Understanding Event Parameters in Google Analytics 4 (GA4)
Event parameters in Google Analytics 4 (GA4) are the additional information about an event that is sent along with the event.
Read more >
Working with Events in JavaScript - Salesforce Developers
Throwing and Handling Errors ... Dynamically Adding Event Handlers To a Component ... event.getParams() returns an object containing all event parameters.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found