canjs / can-query-logic

Perform data queries and compare queries against each other. Provides logic useful for data caching and real-time behavior.

Home Page:https://canjs.com/doc/can-query-logic.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How should types, members, and sets be represented?

justinbmeyer opened this issue · comments

People need to be able to define their own types that work with the set system. There are:

  • Types: Something like Color,
  • Members/instances: Something like "green",
  • Sets: Something like ["green", "red"]

For example, a Todo might have a status property of type Color:

DefineMap.extend({
  status: Color
})

How should types, sets, and members relate to each other?

Option A

  • isMember check on the Type and sets of the type.
  • new Type.Set() to create a subset.
Color = Enum(["red","green", "blue"]);

Color.isMember("red") //-> true

var redAndGreen = new Color.Set(["green","red"]);

redAndGreen.isMember("red") //-> true 

var universal = Color.UNIVERSAL;

set.difference( universal, redAndGreen) //-> new Color.Set(["blue"]);

Questions:

  • Should Color just be the universal set?
  • Should isMember default to instanceOf? I think this should be a can-reflect thing.