Creating A Dativejs Instance
In Dative 2-alpha there are two ways of creating an instance for your application
new Dative
defineApp
The new Dative
is the normal way we know in the v1-v2 but the defineApp
is the new way which also uses the same options api like new Dative
but with the defineApp
you don't need to use the new
keyword
Let's start cooking 🥳🍜
defineApp<T extends DativeOptions>(options: T): Dative
import { defineApp } from 'dativejs'
let app = defineApp({
data: ()=>({
message: "Holla"
}),
template: `
<div>
<h1>{{message}}</h1>
</div>
`
})
Notice That there's not app.render()
again like the v1-v2
The v2-alpha
render automatically when there's an el
options or when you use the app.mount(el: string)
New options has been added to the instance
Check API docs
Next blog will be on the {{#if}}
block
Thanks for reading ❤️❤️
Top comments (0)