# Vanilla JS

`Store#subscribe()` calls callback immediately and subscribes to store changes. It passes store’s value to callback.

```js
import { $profile } from '../stores/profile.js'

$profile.subscribe(profile => {
  console.log(`Hi, ${profile.name}`)
})
```

`Store#listen(cb)` in contrast, calls only on next store change. It could be useful for a multiple stores listeners.

```js
function render() {
  console.log(`${$post.get().title} for ${$profile.get().name}`)
}

$profile.listen(render)
$post.listen(render)
render()
```

See also `listenKeys(store, keys, cb)` to listen for specific keys changes in the map.

***

*Imported from the [Nano Stores README](https://github.com/nanostores/nanostores/blob/1.5.5/README.md#vanilla-js) for version 1.5.5. Improve this page there.*
