0.1.174 • Published 7 years ago

@pilotlab/data v0.1.174

Weekly downloads
-
License
ISC
Repository
gitlab
Last release
7 years ago

@pilotlab/data

Usage

New attribute collections must be initialized at instantiation, with an object or array representing the desired schema for the collection, along with default values.

const schema:any = {
    label: "User",
    value: {
        name: "",
        age: -1,
        superpowers: [ Superpowers.NONE ],
        strength: 0.5
    }
};

const attributeHero:ISuperHero = new AttributeCollection(schema);

In addition to providing default values, this initialization allows the attribute to later be updated and validated against the schema.

attributeHero.update({ name: "Bernard", age: 53, superpowers: [ Superpowers.FREEZE_RAY ], eyeColor: #f00 });

In the case above, the eyeColor property will be ignored, since it wasn't specified in the initial schema.

Now, we can listen for changes to the attribute and respond accordingly.

attributeHero.strength.changed.listen((args:AttributeEventArgs<ISuperHero>) => {
    if (args.attribute.value <= 0) args.attribute.parent.stun();
});
0.1.174

7 years ago

0.1.169

8 years ago

0.1.168

8 years ago

0.1.167

8 years ago

0.1.166

8 years ago

0.1.165

8 years ago

0.1.164

8 years ago

0.1.163

8 years ago

0.1.162

8 years ago

0.1.161

8 years ago

0.1.160

8 years ago

0.1.159

8 years ago

0.1.158

8 years ago

0.1.157

8 years ago

0.1.156

8 years ago

0.1.155

8 years ago

0.1.154

8 years ago

0.1.152

8 years ago

0.1.151

8 years ago

0.1.150

8 years ago

0.1.149

8 years ago

0.1.148

8 years ago

0.1.147

8 years ago

0.1.146

8 years ago

0.1.145

8 years ago

0.1.144

8 years ago

0.1.143

8 years ago

0.1.142

8 years ago

0.1.141

8 years ago

0.1.140

8 years ago

0.1.139

8 years ago

0.1.138

8 years ago

0.1.137

8 years ago

0.1.136

8 years ago

0.1.130

8 years ago

0.1.128

8 years ago

0.1.127

8 years ago

0.1.126

8 years ago

0.1.125

8 years ago

0.1.124

8 years ago

0.1.123

8 years ago

0.1.122

8 years ago

0.1.120

8 years ago

0.1.119

8 years ago

0.1.118

8 years ago

0.1.117

8 years ago

0.1.116

8 years ago

0.1.114

8 years ago

0.1.113

8 years ago

0.1.111

8 years ago

0.1.110

8 years ago

0.1.109

8 years ago

0.1.107

8 years ago

0.1.106

8 years ago

0.1.105

8 years ago

0.1.101

8 years ago

0.1.99

8 years ago

0.1.98

8 years ago

0.1.96

8 years ago

0.1.95

8 years ago

0.1.93

8 years ago

0.1.87

8 years ago

0.1.85

8 years ago

0.1.82

8 years ago

0.1.75

8 years ago

0.1.71

8 years ago

0.1.70

8 years ago

0.1.69

8 years ago

0.1.68

8 years ago

0.1.58

8 years ago