Giter Club home page Giter Club logo

either_dart's Introduction

either_dart's People

Contributors

avdosev avatar jacobaraujo7 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

either_dart's Issues

About add data to list in left part while pagination

I'm using either_dart in getter-setter.
But I'm stuck while adding data to the list. I want to add data to the list using pagination So can you please guide me that how can i add data to the list?

Here is my code,

 Either<List<NotificationResponseData>, Exception> _notificationData = Right(SuccessResultException());
  Either<List<NotificationResponseData>, Exception> get notificationData => _notificationData;
  set notificationData(Either<List<NotificationResponseData>, Exception> value) {
    _notificationData = value;
    // _notificationData.fold((left) => value.left, (right) => value.right);
    notifyListeners();
  }

Cannot mock (mockito) functions which return Either

In 1.0.0 the Either class was sealed. This breaked the generated mocking code for unit tests.

Is there a need for this class to be sealed?

We are forced to remain on version 0.4.0 - please reconsider sealing.

Thank you

Better type for Future<T> fold<T>

Future<T> fold<T>(T Function(L left) fnL, T Function(R right) fnR) {
return this.then((either) => either.fold(fnL, fnR));
}

I am quite new to dart so I may be wrong here (that's why I am creating an issue rather then pull request) but shouldn't fnL and fnR return FutureOr<T> instead of T?

Future<T> fold<T>(FutureOr<T> Function(L left) fnL, FutureOr<T> Function(R right) fnR) {
  return this.then((either) => either.fold(fnL, fnR));
}

This is what this.then() actually expects and it would allow us to do something like this:

bool success = await getStatusAsync()
  .fold(
    (error) async {
      await saveErrorAsync(error);
      return false;
    },
    (status) async {
      await saveStatusAsync(status);
      return true;
    },
);

(it's just and example and my usecase is actually quite different but I also need to fold both left and right to different futures of the same type)

Sealed Classes

https://dart.dev/language/class-modifiers#sealed

Admittedly I haven't dug too deep here - but seems like a sealed annotation would be a nice addition for this lib.

Might need to be a separate package to maintain compatibility with Dart < 3.0.

Happy to take a stab at it at some point in the next week or two if you'd like!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.