# Introduction

This is the Pitcher Core package, a splitted version of @pitcher/vue-sdk which only includes business logic part.

The goal with this package is:

  • provide a framework to speed up Vue.js development
  • provide reusable code building blocks and best practices

@pitcher/core package includes:

# Dependencies

@pitcher/core package simply depends 2 other packages. Make sure you have these packages installed in your project:

  "@vue/composition-api": ">= 1.0.0-rc.1",
  "vue": ">= 2.6.0"

# Installation

To install @pitcher/core package, simply run:

npm install @pitcher/core

# Usage

@pitcher/core package does not need to be initialized or anything similar. Basically just import the functions you need from the package and use e.g.

import { fireEvent } from '@pitcher/core'

fireEvent('TI_EVENT_NAME')

However, if you want to execute actions related to params you need to initialize some stuff before doing anything else.

# Initialization

# getParameters

To get params from Impact, you MUST use loadParams() in the entry point of your application. When you use loadParams() function, @pitcher/core injects window.getParameters function for Impact to be able to call the function and inject params.

After calling loadParams(), we can use the useParamsStore() function anywhere in the application.

WARNING

NOTE: ParamsStore is reactive, which means that if you mutate anything inside the store, it will be updated anywhere else.

# Example - usage with useParamsStore()

// App.vue

import { onMounted } from '@vue/composition-api'
import { loadParams, useParamsStore } from '@pitcher/core'

export default {
  name: 'app',
  setup() {
    onMounted(async () => {
      await loadParams()
      // reactive
      const paramsStore = useParamsStore()

      console.log(paramsStore.state.Account.Id)
    })
  },
}

# Example - usage with useParams()

If you only need to use params and you don't need the store, you can use useParams() to get params only.

// App.vue

import { onMounted } from '@vue/composition-api'
import { loadParams, useParams } from '@pitcher/core'

export default {
  name: 'app',
  setup() {
    onMounted(async () => {
      await loadParams()
      const params = useParams()

      console.log(params.Account.Id)
    })
  },
}