-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
174 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/// Represents a dependency for a server action. | ||
/// | ||
/// The [ActionDependency] class contains information about the dependency target and ID. | ||
final class ActionDependency { | ||
/// The ID of the dependency. | ||
String id; | ||
|
||
/// Name of the target property at resulting object. | ||
String target; | ||
|
||
ActionDependency({ | ||
required this.target, | ||
required this.id, | ||
}); | ||
|
||
/// Creates an instance of [ActionDependency] from a JSON map. | ||
factory ActionDependency.fromJson(Map<String, dynamic> json) { | ||
return ActionDependency( | ||
target: json["target"], | ||
id: json["id"], | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
|
||
import 'package:duit_kernel/src/driver_api/parser.dart'; | ||
|
||
base class ServerEvent { | ||
static late Parser<ServerEvent> _eventParser; | ||
|
||
static set eventParser(Parser<ServerEvent> value) { | ||
_eventParser = value; | ||
} | ||
|
||
final String type; | ||
|
||
ServerEvent({required this.type}); | ||
|
||
static ServerEvent parseEvent(Map<String, dynamic> json) { | ||
return _eventParser.parse(json); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
abstract interface class Parser<T> { | ||
T parse(Map<String, dynamic> json); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters