8000 GitHub - hmmhmmhm/vue-state-store at feature/universal-state ยท GitHub
[go: up one dir, main page]

Skip to content

About

๐Ÿ“ฎ VSS (Vue State Store) - Vue State Management (with Publish & Subscribe pattern)

Resources

Stars

0 stars

Watchers

0 watching

Forks

ย 
ย 

Latest commit

ย 

History

97 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ‡บ๐Ÿ‡ธ MAKE US GREAT AGAIN

VANILLA

// * universal-state

// * ๋ฐ”๋‹๋ผ ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ์—์„œ์˜ ์‚ฌ์šฉ๋ฐฉ๋ฒ•
<script src="https://cdnjs.cloudflare.com/ajax/libs/universal-state/0.0.1/us-vanilla.min.js"></script>

// * ํƒ€์ž…์Šคํฌ๋ฆฝํŠธ ์ƒํƒœ ๊ฐ’ ๋กœ๋“œ
us.load(`
  class Counter {
    count: number = 0
    handle: any = null

    up = () => this.count += 1
    down = () => this.count -= 1

    start = () => {
      this.handle = setInterval(()=> {
        this.count++
      }, 1000)
    }

    stop = () => {
      if(this.handle) clearInterval(this.handle)
    }

    double() {
      return this.count*2
    }
  }
`)

// * ์ €์žฅ์†Œ์˜ ์ค„์ž„๋ง์„ ๋“ฑ๋กํ•ฉ๋‹ˆ๋‹ค.
var Counter = us.store.Counter

// * ์นด์šดํŒ…์„ ์‹œ์ž‘ํ•ฉ๋‹ˆ๋‹ค.
Counter.start()

// * ๋ณ€๊ฒฝ์ ์„ ๊ตฌ๋…ํ•ฉ๋‹ˆ๋‹ค.
us.subscribe(
  // * ๊ตฌ๋…ํ•  ๋Œ€์ƒ ์ง€์ •
  [Counter.count],

  // * ๋ณ€๊ฒฝ์ ์ด ๋ฐœ์ƒํ•  ๋•Œ
  function callback () {
    $('#count').text(Counter.count)
  }
)

About

๐Ÿ“ฎ VSS (Vue State Store) - Vue State Management (with Publish & Subscribe pattern)

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

0