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.

myScopeContainerObject.scope.close() is not working?

See original GitHub issue

Describe the bug Koin version: 2.1.5

myScopeContainerObject.scope.close() behave differently from

val scope = myScopeContainerObject.scope
scope.close

To Reproduce I have an the below scope Object

scope<MyObject> {
    scoped { Presenter() }
}

When I close it, getting it on will crash as expected.

val myScope = myObject.scope
val presenter = myScope.get<Presenter>(Presenter::class.java)
myScope.close()
val presenter2 = myScope.get<Presenter>(Presenter::class.java) // Crash here.

However if I don’t assign out, but close it too. It still works.

val presenter = myObject.scope.get<Presenter>(Presenter::class.java)
myObject.scope.close()
val presenter2 = myObject.scope.get<Presenter>(Presenter::class.java) 
// presenter1 == presenter2

I still can get my presenter the same copy as I get before I close it.

I think there’s a bug somewhere.

More description in https://stackoverflow.com/questions/61321896/koin-why-after-myobject-scope-close-it-still-works

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
arnaudgiulianicommented, Apr 22, 2020

.scope is more a shortcut for getOrCreateScope for the given instance

0reactions
elyecommented, Apr 23, 2020

After trying further, the myObject.scope.close() do work. And the previously assigned myScope will not work anymore. Just that when one perform myObject.scope, it will generate a new one.

This make sense. One just have to be careful, else it will be confusing. Closing the issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Kotlin Koin Scope Illustrated - Medium
myScopeContainerObject.scope.close() is not working? · Issue #786 · InsertKoinIO/koin. You can't perform that action at this time.
Read more >
Scope issues with Angular UI modal - Stack Overflow
Hi, this solved my problem for a while, but noticed a weird thing when closing the modal/dialog, content was changing and it seemed...
Read more >
Solved: HR case is not getting close complete from work In...
Hello All,. when a we changes the HR Case state to Closed complete the case record shows as complete and state changes back...
Read more >
Issue with Close workbook activity - UiPath Forum
Hello, My coding has issues with the closing activity of the Excel. ... that is in scope and not null when using close...
Read more >
SM Work Order Close Form - Viewpoint Help
Selecting Yes closes the work order and all of its open scopes. Once closed, you can no longer add new scopes or trips,...
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