![]() But things get really interesting once we have a way to bind relations at the UI level, and that's where our PLRelationalBinding library comes in. Taken on its own, there are a lot of interesting things happening behind the scenes in PLRelational - efficiently pulling and storing data, using relational algebra to compute derivatives, and so forth. In other words, the Relation API looks the same regardless of how or where the data is stored underneath. There is also support for layering additional functionality, such as caching and change logging, through simple composition. Out of the box, PLRelational has support for data stored in memory, in an SQLite database, or from plist data stored in a single file or spread out over multiple directories. One other great thing about PLRelational is that you can use the same Relation operations to interact with data from different sources. For example, that hypothetical application might have a table view to display the available teams, and the data wouldn't need to be pulled until that table view is loaded for the first time. We simply declare how the data is related, and then PLRelational takes care of efficiently loading and transforming the data as it is needed. Note that in these examples, we're not actually forcing any data to load. Use `difference` to determine which teams are available to join Let selectedEmployeeTeams = employeeTeams We can use relational algebra to find out which teams a certain employee hasn't yet joined: // Figure out which teams the employee *has* already joined ![]() Or suppose we are building an application to manage the company's sports teams. max, count) and other operations like leftOuterJoin that are considered extensions to the relational algebra.įor example, we can find the number of employees in the HR department that like chocolate ice cream: let chocoholicsInHR = employees. PLRelational includes a full set of combinators, including aggregate functions (e.g. join and select) that are familiar if you've spent time with SQL. In the above example, we used some basic relational algebra operations (e.g. Once the update is processed, our observer will see the change will be delivered on the main queue when ready.) (Async updates and queries are processed in the background results Update all employees in the HR department to have the name LindaĪllEmployees.asyncUpdate(Dept.name *= "HR", ) changes, extract the changed name and append to `empThreeNames`. Observe changes made to Cathy's record. Perhaps some example code can help explain what that all means: // Use combinators to `join` our two on-disk relations and `project` observe fine-grained deltas when a relation's data has changed.asynchronously query and update those relations.declaratively express relationships using relational algebra.At its core, PLRelational is a Swift framework that allows you to: PLRelational is our (exploratory) answer to that question. ![]() A question then emerged: can we build a library that allows us to express those transformations in a concise way, with an eye towards simplifying app development? It sounds so simple when boiled down like that, but the reality of app development is a different story, often filled with twisty, error-prone UI code, even with the help of functional programming aids (e.g. While working on the next major version of VoodooPad, an observation was made: user interfaces are basically just bidirectional transformation functions, taking data from some source and presenting it to the user, and vice versa. Reactive Relational Programming with PLRelational
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |