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

7 years ago

0.1.168

7 years ago

0.1.167

7 years ago

0.1.166

7 years ago

0.1.165

7 years ago

0.1.164

7 years ago

0.1.163

7 years ago

0.1.162

7 years ago

0.1.161

7 years ago

0.1.160

7 years ago

0.1.159

7 years ago

0.1.158

7 years ago

0.1.157

7 years ago

0.1.156

7 years ago

0.1.155

7 years ago

0.1.154

7 years ago

0.1.152

7 years ago

0.1.151

7 years ago

0.1.150

7 years ago

0.1.149

7 years ago

0.1.148

7 years ago

0.1.147

7 years ago

0.1.146

7 years ago

0.1.145

7 years ago

0.1.144

7 years ago

0.1.143

7 years ago

0.1.142

7 years ago

0.1.141

7 years ago

0.1.140

7 years ago

0.1.139

7 years ago

0.1.138

7 years ago

0.1.137

7 years ago

0.1.136

7 years ago

0.1.130

7 years ago

0.1.128

7 years ago

0.1.127

7 years ago

0.1.126

7 years ago

0.1.125

7 years ago

0.1.124

7 years ago

0.1.123

7 years ago

0.1.122

7 years ago

0.1.120

7 years ago

0.1.119

7 years ago

0.1.118

7 years ago

0.1.117

7 years ago

0.1.116

7 years ago

0.1.114

7 years ago

0.1.113

7 years ago

0.1.111

7 years ago

0.1.110

7 years ago

0.1.109

7 years ago

0.1.107

7 years ago

0.1.106

7 years ago

0.1.105

7 years ago

0.1.101

7 years ago

0.1.99

7 years ago

0.1.98

7 years ago

0.1.96

7 years ago

0.1.95

7 years ago

0.1.93

7 years ago

0.1.87

7 years ago

0.1.85

7 years ago

0.1.82

7 years ago

0.1.75

7 years ago

0.1.71

7 years ago

0.1.70

7 years ago

0.1.69

7 years ago

0.1.68

7 years ago

0.1.58

7 years ago