Skip to content

Table interfaces #3541

Answered by KrisBraun
KrisBraun asked this question in Q&A
Apr 28, 2025 · 2 comments · 6 replies
Discussion options

You must be logged in to vote

mixins can be used as an interface. You don't need to declare another class.

mixin SyncableTable on Table {
  DateTimeColumn get updatedAt =>
      dateTime()
          .withDefault(currentDateAndTime)
          .map(const LocalDateTimeConverter())();
}

doWork(SyncableTable syncableTable) async {
    syncableTable.updatedAt;
}

Awesome (TIL!) -- using the mixin directly is clearly exactly what I want. Didn't occur to me that it would include the base Table type. Using the mixin directly and removing the abstract class works perfectly.

Replies: 2 comments 6 replies

Comment options

You must be logged in to vote
6 replies
@KrisBraun
Comment options

@dickermoshe
Comment options

@simolus3
Comment options

@KrisBraun
Comment options

Answer selected by KrisBraun
@KrisBraun
Comment options

@simolus3
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants