Hydraulik is an experimental react library for writing state handling components.
import React Component from 'react'import Schema type skip Klass from 'hydraulik'import Str from 'hydraulik-types'@extend Schemavar klass =klassklassvar users = klasssetsusersuser = klasssetsuserusersusers// these components automatically listen for changed datavar UserList = users
After writing several apis and single page apps I've got frustrated with repeating myself over and over again. I want to define how my data behaves declaritive. With as little mental overhead as possible.
mkdir $projectNamecd $_npm initnpm install hydraulik-cli --save-dev/hydraulik initnpm install# or in one linemkdir $projectName && cd $_ && npm init && npm install hydraulik-cli --save-dev && /hydraulik init && npm install
Hydraulik uses jest for testing. You can run its test by
$ npm test.
If it dosn't work try running
$ nvm use in the hydraulik dir and reinstall the dependencies.
Schema - Set
@type(type: Type, [name = typeName], [preset = null])
Takes a Type that implement this interface. The name of the type is the Types name downcased. You can overwrite the type behavior on an child class. preset == default value. Only if value null or undefiend.
@skip() skips as many matches as provided in props.skip. defaults to 0 if params.skip isn't defined @skip(int) skips as many as are defined for int
if skip is 0 nothing is skiped
@limit() limits as many matches as provided in props.limit. defaults to 0 if params.limit isn't defined @limit(int) limits as many as are defined for int
if limit is 0 nothing is limited if limit is 1 it returns the element without the surrounding array
filters the set. FilterFn has to return a boolean. Val is an element of the set. You can access args from outside via val.params. Params from the component
instances of the ObserverSet/ObserverSubset are stored in the Klass instance variable sets.
update(argObj: Object, query: Object)
Issues & Feature Requests
If you encounter a bug, inconsistencies or if anything isn't clear or clear enough open an issue. If you want a feature. Open an issue and we will discuss it. I'm happy to introduce you to hydraulik's code base. Feel free to reopen issues and claim unassigned issues for yourself to solve. The issue doesn't have to be code relatet. If you think that there can be something done with this projects organization open an issue.
The source code lives in the src folder.
exports all classes that can be accessible through
import * from 'hydraulik'
The Class contains all sets. Builds sets if #sets is called the first time. Build with the klassBuilder.
It makes that the BaseSet and SubSet share the same storage. Converts sets into observed sets
inherits from observerSubset and registers new action to the dispatcher
The adapter for the different set types. The user interacts with its methods.
The DSL for Hydraulik.
decorators for the schema.
TODO - move to own module sets provide crud operations and validation for an data table
The events an observer set listens to.
- add a server/websocket set
- add relations and co-dependent constrains.
- remove the need to register a schema manually.