// Thin Composables
/*
Thin composables introduce an additional layer of abstraction, separating the reactivity management from the core business logic. 
Here we use plain JavaScript or TypeScript for business logic, represented as pure functions, with a thin layer of reactivity on top.
*/

import { ref, watch } from 'vue';
import { convertToFahrenheit } from './temperatureConversion';

export function useTemperatureConverter(celsiusRef: Ref<number>) {
  const fahrenheit = ref(0);

  watch(celsiusRef, (newCelsius) => {
    // Actual logic is contained within a pure function
    fahrenheit.value = convertToFahrenheit(newCelsius);
  });

  return { fahrenheit };
}