<commit_before>package io.udash.core

import io.udash.properties.HasModelPropertyCreator
import org.scalajs.dom._

import scalatags.generic.Modifier

/**
  * Url wrapper - just for avoiding strings.
  */
case class Url(value: String) extends AnyVal
object Url extends HasModelPropertyCreator[Url]

/**
  * The Presenter should contain all business logic of a view: user interaction callbacks, server communication.
  * It should not call any methods of a View class. The View and the Presenter should communicate via Model properties.
  * When implementing Presenter, you should remember, that a handleState method can be called not only on view initialization.
  *
  * @tparam S State for which this presenter is defined.
  */
trait Presenter[S <: State] {
  /**
    * This method will be called by [[io.udash.routing.RoutingEngine]] when relevant state need to be resolved.
    * It can be uses to get parameters from state and use it to call eg. external API.
    *
    * @param state the instance of resolved state
    */
  def handleState(state: S): Unit

  /**
    * This method will be called by [[io.udash.routing.RoutingEngine]] when this presenter will be replaced
    * by other presenter. In this callback you should do cleanup if needed.
    */
  def onClose(): Unit = ()
}

/**
  * The ViewFactory has to prepare model, [[io.udash.core.View]], [[io.udash.core.Presenter]] and link them together.
  *
  * @tparam S State for which this pair is defined.
  */
trait ViewFactory[S <: State] {
  /**
    * Factory method which should return ready to used instance of [[io.udash.core.Presenter]] and [[io.udash.core.View]].
    *
    * @return pair of presenter and view for state S<commit_msg>Introduce contravariance to Presenter<commit_after>package io.udash.core

import io.udash.properties.HasModelPropertyCreator
import org.scalajs.dom._
import scalatags.generic.Modifier

/**
  * Url wrapper - just for avoiding strings.
  */
case class Url(value: String) extends AnyVal
object Url extends HasModelPropertyCreator[Url]

/**
  * The Presenter should contain all business logic of a view: user interaction callbacks, server communication.
  * It should not call any methods of a View class. The View and the Presenter should communicate via Model properties.
  * When implementing Presenter, you should remember, that a handleState method can be called not only on view initialization.
  *
  * @tparam S State for which this presenter is defined.
  */
trait Presenter[-S <: State] {
  /**
    * This method will be called by [[io.udash.routing.RoutingEngine]] when relevant state need to be resolved.
    * It can be uses to get parameters from state and use it to call eg. external API.
    *
    * @param state the instance of resolved state
    */
  def handleState(state: S): Unit

  /**
    * This method will be called by [[io.udash.routing.RoutingEngine]] when this presenter will be replaced
    * by other presenter. In this callback you should do cleanup if needed.
    */
  def onClose(): Unit = ()
}

/**
  * The ViewFactory has to prepare model, [[io.udash.core.View]], [[io.udash.core.Presenter]] and link them together.
  *
  * @tparam S State for which this pair is defined.
  */
trait ViewFactory[S <: State] {
  /**
    * Factory method which should return ready to used instance of [[io.udash.core.Presenter]] and [[io.udash.core.View]].
    *
    * @return pair of presenter and view for state S
{'fraction_non_alphanumeric': 0.08897316219369895, 'fraction_numerical': 0.0, 'mean_word_length': 3.5, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6198738', 'n_tokens_mistral': 963, 'n_tokens_neox': 973, 'n_words': 412}