Skip to content

Releases: FancyNeuron/spellbind

0.4.1

24 Jul 14:08

Choose a tag to compare

New Features

  • Value[S] inherits from BiObserver[S, S] again
  • Add classes StaticObservableSequence[S] and FrozenObservableSequence[S], both are unchanging sequences, but FrozenObservableSequence[S] is hashable (and therefore requires all its elements to be hashable), like frozenset.

Improvements

  • mypy is now executed in strict mode, improving code quality
  • No longer importing protected names (except for base classes)
  • Moving some number related functions from spellbind.functions to spellbind.numbers and make them not protected

Bug fixes

  • Fix type_extensions not imported error, by moving type_extensions from test dependencies to regular project dependencies

Breaking Changes

  • Renamed Value[S].bind_to to Value[S].bind, marking the old variant as deprecated
  • Replaced Observable.__or__, with Observable.or_observable, because it would conflict with BoolValue.__or__. ALternatively use observables.combine_observables, which takes any number of observables
  • Renamed methods map, map_to_two, or_value, etc.. to less verbose names, to better distinguish them from methods on Value[S]

Introduce observable collections

19 Jul 01:08
1e960ff

Choose a tag to compare

New Features

  • New observable collections. ObservableList[S] lets you collect stuff in a list which you can observe for changes. ValueList[S] lets you add Value[S], of which changes you will also be notified when observing the collection
  • Also Added ObservableIntList, IntValueList, ObservableStrList and StrValueList, which provide useful helper methods
  • Variable[S] not has set_delay_notify, a context manager which allows you to set a value, but not have its listeners notified immediately
  • New classes ValuesObservable and ValuesEvent, which allows observing iterables, either as an Iterable or as each individual element
  • Added emit_lazy method to all Events, allowing you to create values, only when the event really is listened to
  • Observables now have various map methods, to map to other observers from other Observables with a mapping function. Events will know if all their observers are themselves unobserved Observables and not emit even then.
  • Value[S]s can now additionally be observed with functions that take two parameters. In that case, the first is the new value and the second is the old value

Improvements

  • Deriving Values from other Values will return a Constant if it is derived from only constants
  • Constant are now equal to each other if their value is equal

Bug fixes

None

Breaking Changes

  • Value[S]s are no longer Observable themselves. Instead, they now provide a observable property
  • Renamed Value[S].is_dependent_on to Value[S].is_derived_from

Flatten nested Values with associative transformers

30 Jun 11:54
77976c4

Choose a tag to compare

New Features

  • Add many Value creation functions, like float_values.min_float, int_values.sum_ints and str_values.concatenate
  • Add StrValue.length -> IntValue
  • Allow caching of StrConstants with StrConstant.of("foo", cache=True)

Improvements

  • Adding, Multiplying, concatenating and many other associative operations on nested Values will now be flattened. This will reduce complexity of derived Value structures
  • Values derived entirely of constants or literals are now themselves constants. So IntConstant(3) + IntConstant(5) == IntConstant(8). This will reduce complexity of derived Value structures in some situations
  • Caching some constants, like ints in range [-100, 100], floats in range [-100.0, 100.0], bools {True, False} and some select single str chars
  • Other small performance improvements

Bug fixes

None

Breaking Changes

  • Removed many classes, like ClampFloatValue, which have been replaced more general classes, like ThreeFloatToFloatValue

logical operators, BoolValue.select, .clamp, big Value base class rewrite and more

12 Jun 14:45
cc39dd1

Choose a tag to compare

New Features

  • Added logical operators &, |, ^ to BoolValue
  • Added BoolValue.select, which works as a sort of if-then-else
  • Added IntValue.clamp and FloatValue.clamp

Improvements

  • Big Value base classes rework. Made naming of base classes more coherent and made many not abstract (instead of abstrct transoform function, they take a callable)
  • Increased code test coverage to 100%
  • Make Observables inherit from each other, so functions that take an Observable will also take a BiObservable

Bug fixes

  • Fix bug in MappedValue (now called OneToOneValue), caused by improper initialization order of fields and init call

Breaking Changes

  • Renamed some classes, like MappedValue to OneToOneValue and CombinedTwoValues to TwoToOneValue

Added min/max/map values and improve binding

11 Jun 00:57
55cadf3

Choose a tag to compare

New Features

  • Added MinIntValues, MaxIntValues, MinFloatValues, and MaxFloatValues classes for value aggregation
  • Added mapping methods to Value class: map(), map_to_int(), map_to_float(), map_to_str(), map_to_bool()
  • Added times parameter to binding methods, allowing observation limits

Improvements

  • Derived Values now bind weakly by default, reducing memory leaks from circular references

Breaking Changes

  • None

Support for more arithmetic operations

09 Jun 12:21
957c140

Choose a tag to compare

New Features

  • Added pow, mod, abs, pos operators to IntValue and FloatValue
  • Added round(), floor(), and ceil() methods to FloatValue

Breaking Changes

  • None

Initial Release

09 Jun 10:46
b279d40

Choose a tag to compare

Initial Release

spellbind - A reactive programming library for Python with observable values and events.

See the README for full documentation, examples, and installation instructions.

Requirements

  • Python 3.10+
  • No external dependencies