-
Notifications
You must be signed in to change notification settings - Fork 6
[DRAFT] mapDataToProps
Thom van Kalkeren edited this page Aug 12, 2019
·
7 revisions
So, this isn't how the current mapDataToProps
interface works, but an effort to design a less flexible but more powerful and consistent interface.
const collectionMembers = [NS.as('pages'), NS.as('items'), NS.rdfs('member')];
const Component = ({
somePropName,
customProp,
someNestedContainer,
someDeeplyNestedProperty,
deeplyNestedWhereMatches,
}) => {
console.log(somePropName); // 'name value'
console.log(customProp); // [Statement(NamedNode(s), p, o, g), ...]
console.log(someNestedContainer); // [NamedNode('seq 1'), NamedNode('seq 2')]
console.log(someDeeplyNestedProperty); // [NamedNode('closed member'), NamedNode('open member'), ...]
console.log(deeplyNestedWhereMatches); // [NamedNode('open member'), ...]
}
Component.mapDataToProps = {
name: string(NS.schema.name),
// The raw interface the other helper functions boil down to
customProp: {
transform: (i) => i,
label: NS.ex('prop'),
limit: Infinity,
returnType: 'statement'
},
// arr can resolve native rdf container types (rdf:Bag/Seq, rdf:List)
someNestedContainer: arr({
label: NS.ex('somePropWithRDFSRangeRDFContainer')
}),
someDeeplyNestedProperty: dig(collectionMembers),
deeplyNestedWhereMatches: findSubject(collectionMembers, NS.ex('state/open')),
}