0.7.218 • Published 2 days ago

objy v0.7.218

Weekly downloads
24
License
MIT
Repository
github
Last release
2 days 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.218

2 days ago

0.7.217

1 month ago

0.7.216

2 months ago

0.7.215

3 months ago

0.7.214

3 months ago

0.7.213

4 months ago

0.7.2

4 months ago

0.7.211

4 months ago

0.7.212

4 months ago

0.7.1

6 months ago

0.7.0

7 months ago

0.6.994

7 months ago

0.6.993

7 months ago

0.6.992

7 months ago

0.6.991

8 months ago

0.6.999

7 months ago

0.6.998

7 months ago

0.6.997

7 months ago

0.6.996

7 months ago

0.6.989

8 months ago

0.6.988

8 months ago

0.6.990

8 months ago

0.6.987

9 months ago

0.6.986

1 year ago

0.6.985

2 years ago

0.6.984

2 years ago

0.6.982

3 years ago

0.6.981

3 years ago

0.6.979

3 years ago

0.6.980

3 years ago

0.6.978

3 years ago

0.6.977

3 years ago

0.6.976

3 years ago

0.6.975

3 years ago

0.6.973

3 years ago

0.6.972

3 years ago

0.6.971

3 years ago

0.6.97

3 years ago

0.6.94

3 years ago

0.6.93

3 years ago

0.6.96

3 years ago

0.6.974

3 years ago

0.6.95

3 years ago

0.6.92

3 years ago

0.6.91

3 years ago

0.6.90

3 years ago

0.6.89

3 years ago

0.6.87

3 years ago

0.6.88

3 years ago

0.6.86

3 years ago

0.6.83

3 years ago

0.6.82

3 years ago

0.6.85

3 years ago

0.6.84

3 years ago

0.6.81

3 years ago

0.6.67

3 years ago

0.6.66

3 years ago

0.6.69

3 years ago

0.6.68

3 years ago

0.6.76

3 years ago

0.6.75

3 years ago

0.6.78

3 years ago

0.6.77

3 years ago

0.6.72

3 years ago

0.6.71

3 years ago

0.6.74

3 years ago

0.6.73

3 years ago

0.6.79

3 years ago

0.6.70

3 years ago

0.6.65

3 years ago

0.6.63

3 years ago

0.6.62

3 years ago

0.6.61

3 years ago

0.6.6

3 years ago

0.6.5

3 years ago

0.6.4

3 years ago

0.6.3

3 years ago

0.6.2

3 years ago

0.6.1

3 years ago

0.5.130

3 years ago

0.5.132

3 years ago

0.5.131

3 years ago

0.5.129

3 years ago

0.5.128

3 years ago

0.5.125

3 years ago

0.5.127

3 years ago

0.5.124

3 years ago

0.5.123

3 years ago

0.5.126

3 years ago

0.5.122

3 years ago

0.5.121

4 years ago

0.5.120

4 years ago

0.5.119

4 years ago

0.5.118

4 years ago

0.5.117

4 years ago

0.5.116

4 years ago

0.5.115

4 years ago

0.5.114

4 years ago

0.5.113

4 years ago

0.5.112

4 years ago

0.5.110

4 years ago

0.5.111

4 years ago

0.5.109

4 years ago

0.5.108

4 years ago

0.5.107

4 years ago

0.5.106

4 years ago

0.5.104

4 years ago

0.5.103

4 years ago

0.5.102

4 years ago

0.5.101

4 years ago