0.7.228 • Published 5 months ago

objy v0.7.228

Weekly downloads
24
License
MIT
Repository
github
Last release
5 months ago

OBJY - Abstract, powerful JavaScript objects

An object-driven programming framework, that uses behaviour-driven objects for building use cases.

FULL DOCUMENTATION

OBJY LOGO

OBJY Objects:

  • are plain JavaScript objects
  • have dynamic origins
  • have behaviour
  • and more...

Installing

Node

npm install objy

Browser

<script src="https://cdn.jsdelivr.net/npm/objy/dist/browser.js">

Quick example

Programming on OBJY is done in two simple steps:

  1. Define an object family (a bucket of objects)
  2. Build and handle objects and tell them what to do.
// 1. Define Object Family
OBJY.define({
   name: "object", // singular constructor name
   pluralName: "objects" // plural constructor name
})

// 2. Use objects
OBJY.object({
   expired: false,
   expiration_date: {
      date: "12/31/2022",
      action: () => {
         obj.setProperty('expired', true).update();
      }
   },
   maintenance: {
      interval: "1PY",
      action: () => {
         console.log('annually maintenence');
      }
   }
})

Handling objects

Objects are handled using an OBJY wrapper: OBJY.object().

// Create an object (onCreate handlers will trigger)
var myObj = OBJY.object({
   name: "Hello"
}).add();

// Update an object (onChange handlers will trigger)
myObj.name = "Hello World";

// or use the built-in methods:
myObj.addProperty('color', 'blue');

// Delete an object (onDelete handlers will trigger)
myObj.remove();

Date or interval-based events:

Events can either have a date or an interval. OBJY takes care of running the associated action.

OBJY.object({
   ...
   expiration_date: {
      date: "12/31/2022",
      action: () => {
         obj.setProperty('expired', true).update();
      }
   },
   maintenance: {
      interval: "1PY",
      action: () => {
         console.log('annually maintenence');
      }
   }
})

Handlers

Use onCreate, onChange or onDelete to capture these events and OBJY runs a custom action.

OBJY.object({
   ...
   onDelete: {
      quit: {
         action: () => {
            console.log('Im now gone...')
         }}
   }
})

Inheritance

// first object
OBJY.object({
   _id: 123,
   type: "yogurt"
})
// second object that inherits from first object
// inherit from one or more other objects using their id
OBJY.object({
   ... 
   inherits: [123], 
   // type: "yogurt" and all other props are present here
})

Querying objects

Every object you create lives inside the OBJY instance. For accessing and working with all your objects, OBJY offers the following built-in query API:

// Query all active objects
OBJY.objects({json query}).get(objects => {
   console.log(objects) // an array containing the matched objects
})

Custom Mappers

OBJY.define({
   ...
   // Attach your own storage (can be anything that supports crud)
   storage: OBJY.customStorage({
      add: () => {},
      getById: () => {},
      ...
   }),
   // Customize, how actions are executed
   processor: OBJY.customProcessor({
      execute: (action) => {}, 
      ...
   }),
   // Observe events yourself
   observer: OBJY.customObserver({
      run: () => {}
   })
})
0.7.226

6 months ago

0.7.225

6 months ago

0.7.228

5 months ago

0.7.227

5 months ago

0.7.224

9 months ago

0.7.223

9 months ago

0.7.220

11 months ago

0.7.222

10 months ago

0.7.221

11 months ago

0.7.219

11 months ago

0.7.218

1 year ago

0.7.217

1 year ago

0.7.216

1 year ago

0.7.215

1 year ago

0.7.214

1 year ago

0.7.213

1 year ago

0.7.2

1 year ago

0.7.211

1 year ago

0.7.212

1 year ago

0.7.1

2 years ago

0.7.0

2 years ago

0.6.994

2 years ago

0.6.993

2 years ago

0.6.992

2 years ago

0.6.991

2 years ago

0.6.999

2 years ago

0.6.998

2 years ago

0.6.997

2 years ago

0.6.996

2 years ago

0.6.989

2 years ago

0.6.988

2 years ago

0.6.990

2 years ago

0.6.987

2 years ago

0.6.986

2 years ago

0.6.985

3 years ago

0.6.984

3 years ago

0.6.982

4 years ago

0.6.981

4 years ago

0.6.979

4 years ago

0.6.980

4 years ago

0.6.978

4 years ago

0.6.977

4 years ago

0.6.976

4 years ago

0.6.975

4 years ago

0.6.973

4 years ago

0.6.972

4 years ago

0.6.971

4 years ago

0.6.97

4 years ago

0.6.94

4 years ago

0.6.93

4 years ago

0.6.96

4 years ago

0.6.974

4 years ago

0.6.95

4 years ago

0.6.92

4 years ago

0.6.91

4 years ago

0.6.90

4 years ago

0.6.89

4 years ago

0.6.87

4 years ago

0.6.88

4 years ago

0.6.86

4 years ago

0.6.83

4 years ago

0.6.82

4 years ago

0.6.85

4 years ago

0.6.84

4 years ago

0.6.81

4 years ago

0.6.67

4 years ago

0.6.66

4 years ago

0.6.69

4 years ago

0.6.68

4 years ago

0.6.76

4 years ago

0.6.75

4 years ago

0.6.78

4 years ago

0.6.77

4 years ago

0.6.72

4 years ago

0.6.71

4 years ago

0.6.74

4 years ago

0.6.73

4 years ago

0.6.79

4 years ago

0.6.70

4 years ago

0.6.65

4 years ago

0.6.63

4 years ago

0.6.62

4 years ago

0.6.61

4 years ago

0.6.6

4 years ago

0.6.5

4 years ago

0.6.4

4 years ago

0.6.3

4 years ago

0.6.2

4 years ago

0.6.1

4 years ago

0.5.130

4 years ago

0.5.132

4 years ago

0.5.131

4 years ago

0.5.129

4 years ago

0.5.128

4 years ago

0.5.125

4 years ago

0.5.127

4 years ago

0.5.124

4 years ago

0.5.123

4 years ago

0.5.126

4 years ago

0.5.122

5 years ago

0.5.121

5 years ago

0.5.120

5 years ago

0.5.119

5 years ago

0.5.118

5 years ago

0.5.117

5 years ago

0.5.116

5 years ago

0.5.115

5 years ago

0.5.114

5 years ago

0.5.113

5 years ago

0.5.112

5 years ago

0.5.110

5 years ago

0.5.111

5 years ago

0.5.109

5 years ago

0.5.108

5 years ago

0.5.107

5 years ago

0.5.106

5 years ago

0.5.104

5 years ago

0.5.103

5 years ago

0.5.102

5 years ago

0.5.101

5 years ago