mimir
mimir copied to clipboard
Dart 3 (Macros & Native Assets) Migration
Planned Dart 3 (Macros) Migration
- [ ] Update & add docs
- [ ] Update & add to README
- [ ] Update & add tests
- [ ] Add new examples with macros
mimir
- [ ] Rename
MimirIndextoRawMimirIndex? Maybe we could add a type alias and deprecate one? - [ ]
TypedMimirIndex(created in macros):class TypedMimirIndex<T> {…}- An adapter around
RawMimirIndexthat handles JSON conversions
- An adapter around
- [ ] Macro that defines
extension on MimirInstancethat has aTypedMimirIndex<ClassName> get classNameIndexfor a certain user-definedClassName- Instead of depending on a JSON package, ideally we can just check for the existence of
toMap/toJsonandfromMap/fromJsonin macros placed onClassName
- Instead of depending on a JSON package, ideally we can just check for the existence of
- [ ] Macro that adds static
wheremethod(s) on each user-defined class for easier & type-safe queries (supportingString,number, andboolean).- E.g., for
@mimir class Movie {...}, we could have something likeMimir.and([Movie.whereTitleIsEqualTo('Forrest Gump'), Movie.whereYearIsBetween(2000, 2010)])orMimir.and([Mimir.where(titleIsEqualTo: 'Forrest Gump'), Mimir.where(yearIsBetween: (2000, 2010))]) - Instead of just one
wheremethod, which would be nice/concise, I think it would be better to add several functions for each field. Reason being:isBetweenrequires anandparameter, which cannot be type-safe. Also, multiple methods for each field forces the method use to be checked at compile time instead of runtime (say, if a user specifies bothisEqualToandisGreaterThaninside the same.where()) - Actually, revisiting this, perhaps we can make the
isBetweenfield atuplewhen records/patterns are supported in Dart 3. Although we will still have the issue where you can have multiple things defined in the samewherecall, perhaps we can add a fewwherevariants:whereOr&whereAnd, which break down their members intoMimir.orandMimir.andfor convenience.
- E.g., for
- [ ] Macro that adds
SortBygenerators for each field- Proposed API:
Movie.sortByAsc.titleandMovie.sortByDesc.year, for example, would simply returnSortBy.asc('title')andSortBy.desc('year')
- Proposed API:
- [ ] Native Assets instead of custom packaging system in
flutter_mimir
Note: there will be no extension methods placed on user-defined classes (i.e. create(), updateWith(), delete()) in plain mimir because there is no way to know the associated instance.
While we could add our own _mimirInstance field to user-defined classes, this approach has numerous issues.
flutter_mimir
- [ ] Remove re-export of mimir, and update README with so
- [ ] Not great to re-export right now anyways, but mimir API bindings rely on a particular binary, so flutter_mimir has to enforce this by including a bundled version.
- [ ]
defaultMimirInstancemacro that adds methods to user-defined classes- [ ] I am inclined to do this as it is super convenient; however, I feel like it might open people up to some anti-patterns (using static members instead of DI)
- [ ] Think we can come to good compromise by stating dangers in documentation
- [ ] Possible because we can use the
defaultInstancedirectly viaMimir.defaultInstance - [ ]
create(),updateWith(…),delete()methods planned- [ ]
create()can probably just callupdateWith(...)for its implementation
- [ ]
- [ ] static
search(),searchStream(),documents, ... to each class as static as well
- [ ] I am inclined to do this as it is super convenient; however, I feel like it might open people up to some anti-patterns (using static members instead of DI)
If anyone sees this issue, please feel free to chime in on the proposed changes for Dart 3 above! Would be nice to have some feedback from people using the library.