-
-
Save secondsun/dcf5682b6ff17c729d9a to your computer and use it in GitHub Desktop.
Junction Android
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
public interface Junction<Parent, Child> { | |
read(Parent parent, Callback<List<Child>> callback); | |
} |
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
public JunctionApplication extends Application { | |
onCreate() { | |
Pipeline pipeline = new Pipeline(); | |
pipeline.pipe(Player.class); | |
pipeline.pipe(Team.class); | |
} | |
getPlayers(Callback<List<Player>> callback) { | |
pipe.get("player").read(callback); | |
} | |
getTeams(Callback<List<Team>> callback) { | |
pipe.get("team").read(callback); | |
} | |
getPlayersOnTeam(Team team, Callback<List<Player>> callback) { | |
pipe.junction("team","player").read(team, callback); | |
} | |
getTeamsPlayerHasPlayerFor(Player player, Callback<List<Team>> callback) { | |
pipe.junction("player","team").read(player, callback); | |
} | |
} | |
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
class Player { | |
@RecordId | |
Long id; | |
String name; | |
List<Team> teamsPlayedFor; | |
Team currentTeam; | |
} | |
class Team { | |
@RecordId | |
Long id; | |
String name; | |
List<Player> currentPlayers; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment