Skip to content

DisposeScope but without dispose() #20

@bartekpacia

Description

@bartekpacia

When I pass a parent dispose scope to some class, that class can dispose the parent dispose scope I passed into it. I think this can be a source of bugs in larger codebases and should be addressed somehow.

Example:

class IOSDriver extends PlatformDriver {
  IOSDriver(
    DisposeScope parentDisposeScope,
  ) : _disposeScope = DisposeScope() {
    _disposeScope.disposedBy(parentDisposeScope);
   parentDisposeScope.dispose(); // I don't want to be able to do this!
  }

  final DisposeScope _disposeScope;

  // more methods
}

We could have some interface, e.g DisposeScopeRef (terrible name), that would have only the addDispose method. DisposeScope would implement DisposeScopeRef.

cc: @RobertOdrowaz

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions