npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

oobe

v0.3.1

Published

Wow, write form so fantastic, so fun.

Downloads

22

Readme


Introduction

When business logic and user interface are entangled, change is hard; when logic doesn't depend on UI, your interface becomes easier to work with. --backbone.js

Our goal is build a vue library that focus on model processing, Not like backbone.js and vue-mc that overly powerful library.

data

Although oobe is written for the vue.js, but only for optimized not a vue.js plugin, it can run include nodejs anywhere.


Javascript Class Instance Pattern

// User.js
class User {
    constructor(source = {}) {
        this.name = source.name || ''
        this.phoneNumber = source.phoneNumber || ''
    }
}
<template>
    <div>
        <input v-model="user.name">
        <input v-model="user.phoneNumber">
    </div>
</template>
<script>
    import User from 'User.js'
    export default {
        data() {
            return {
                user: new User({
                    name: 'admin'
                })
            }
        }
    }
</script>

Use oobe

We can use oobe to achieve the same effect:

// profile.js
export default {
    body() {
        return {
            name: '',
            phoneNumber: ''
        }
    },
    born(source = {}) {
        // If source haven't body definition the key, use default.
        return source
    }
}
// oobe.js
import Oobe from 'oobe'
import profile from './profile.js'
let oobe = new Oobe()
oobe.join('User' {
    sprites: { profile }
})
<template>
    <div>
        <input v-model="user.name">
        <input v-model="user.phoneNumber">
    </div>
</template>
<script>
    import oobe from './oobe'
    export default {
        data() {
            return {
                user: oobe.make('User', 'profile').$born({
                    name: 'admin'
                })
            }
        }
    }
</script>

Sprite is Not A Normal Instance

Make() will create an instance via object factory bind some method and status, no need to complex the inheritance trees to get these capabilities, we called this product sprite.

System metohds

let user = oobe.make('User', 'profile').$born()
console.log(user.$isChange()) // false
user.name = 'test'
console.log(user.$isChange()) // true

Status

let user = oobe.make('User', 'profile').$born()
console.log(user.$error) // undefined
user.$setError('error')
console.log(user.$error) // 'error'

Event

let user = oobe.make('User', 'profile')
user.$on('$ready', () => {
    console.log('ready')
})
user.$born() // 'ready'

Collection

let users = oobe.collection('User', 'profile')
let items = []

items.push({
    user: 'admin'
})
items.push({
    user: 'guest'
})

users.batchWrite(items)
console.log(users.items[0].name) // admin

For Ajax

Not like the new keyword we often used, Sprite complete construction needs to call $born(), because ajax have null, success, error three status, we can use control to change with the current state.

let sprtie = oobe.make('User', 'profile')
axios
    .get('./user')
    .then(result => sprite.$born(result.data))
    .catch(error => sprite.$setError(error))

Container And Sprite

Here are two example tables of the classification pattern determined from the database association design:

users

| name | phoneNumber | | ------------- | ------------- | | admin | +886928000000 |

user-metadatas

| name | key | value | | ------------- | ------------- | ------------- | | admin | age | 25 |

Result data

Server side echo maybe the following two format:

User
{
    "name": "admin",
    "phoneNumber": "+886928000000",
    "metadatas": {
        "age": 25
    }
}
Metadata
{
    "name": "admin",
    "age": 25
}

This is the same series just bifurcation to two instances, therefore we decide the following data structure:

let user = {
    body() {
        return {
            name: '',
            phoneNumber: ''
        }
    },
    refs: {
        metadatas: 'metadatas'
    }
}

let metadatas = {
    body() {
        return {
            age: null
        }
    },
    methods: {
        isAdult() {
            return this.age > 18
        }
    }
}

let container = {
    sprites: {
        user,
        metadatas
    }
}

let oobe = new Oobe()

oobe.join('User', container)

// If api result data like this:
let result = {
    name: 'admin',
    phoneNumber: '+886928000000',
    metadatas: {
        age: 25
    }
}

let sprite = oobe.make('User', 'user').$born(result)

console.log(sprite.metadatas.$fn.isAdult()) // true

Learn More

Example

Document

Getting started(TW)


Installation

Web

<script src="./dist/index.js"></script>
<script>
    let oobe = new Oobe()
</script>

Webpack

$npm i --save oobe
import Oobe from 'oobe'
let oobe = new Oobe()

Node

$npm i --save oobe
let Oobe = require('oobe')
let oobe = new Oobe()

Browsers support

| IE / Edge | Firefox | Chrome | Safari | iOS Safari | Samsung | Opera | | --------- | --------- | --------- | --------- | --------- | --------- | --------- | | Edge| support| support| support| support| support| support

In theory, it can be supported by IE11, but the defaultView will be ignored it is adopted.


Other

medium

versions