Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

alt

Package Overview
Dependencies
Maintainers
1
Versions
70
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

alt - npm Package Versions

1
7

0.16.7

Diff

Changelog

Source

0.16.7

Added

  • interceptResponse method to data sources commit

Fixes

  • Revert breaking change back to merge state. 0.17.0 will include bootstrap, recycle, and flush replace state instead of merge state. commit

Changed

  • local method in data source must return null or undefined to trigger remote commit
goatslacker
published 0.16.6 •

Changelog

Source

0.16.6

Fixes

  • Fixes bug with recycle for keys that weren't set at the beginning. commit
  • Fixes isLoading for multiple async calls. commit
goatslacker
published 0.16.5 •

Changelog

Source

0.16.5

Added

  • @decorate(alt) to decorate your store and activate all @bind and @expose methods. commit
  • getStores in conenctToStores decorator/wrapper function now receives props from a store. commit
  • Solving the async debate. commit
goatslacker
published 0.16.4 •

Changelog

Source

0.16.4

Added

  • @bind and @expose decorators for binding actions and exporting public methods. commit
  • Made the lifecycles eventemitters so you can bind multiple. commit

Fixes

  • Bug with react-native. Stop using the Object.assign polyfill since react-native overrides it with a non-spec compliant one. commit
goatslacker
published 0.16.3 •

Changelog

Source

0.16.3

Dependencies

  • Updates es-symbol.
goatslacker
published 0.17.0-alpha1 •

goatslacker
published 0.16.2 •

Changelog

Source

0.16.2

Added

  • Now passing more information through the dispatch about the action invoked. commit
goatslacker
published 0.16.1 •

Changelog

Source

0.16.1

This release is a pretty big one and it also marks Alt's first breaking changes.

Breaking Changes

Upgrade guide is included with each bullet point.

  • New method signatures for createStore, createActions, etc. commit

    Upgrade Guide

    • Previously all constructors for stores and actions received the alt instance as its first argument.
    • You now have to pass this in yourself.
// old behavior

class MyStore {
  constructor(alt) { }
}
// allows you to pass in your own arguments to the constructors

class MyStore {
  constructor(alt, one, two, three) { }
}

alt.createStore(MyStore, null, alt, 1, 2, 3)
  • beforeEach/afterEach methods have been moved to lifecycle. commit

    Upgrade Guide

    • Previously the beforeEach and afterEach methods existed as a prototype method on the store.
    • Now they are lifecycle methods.
// the new way

class Store {
  constructor() {
    this.on('beforeEach', () => {
    });
  }
}
  • withAltContext is now in decorator form. commit

    Upgrade Guide

    • Previously withAltContext took two arguments. The flux and the component.
    • Now it takes a single argument, flux. It returns a function which takes another argument, the component.

    As a decorator:

    @withAltContext(alt)
    export default class App extends React.Component {
      render() {
        return <div>{this.context.flux}</div>
      }
    }
    

    As a function:

    export default withAltContext(alt)(App);
    
  • Lifecycle method serialize and deserialize have been renamed and moved. commit

    Upgrade Guide

    • Rename serialize to onSerialize.
    • Rename deserialize to onDeserialize.
    • Move those methods to your Store's configuration.
    // new hotness
    class TodoStore {
      static config = {
        onSerialize() {
        },
    
        onDeserialize() {
        }
      }
    }
    
  • atomicTransactions util has been renamed to just atomic. commit

    Upgrade Guide

    • Change all your import/require from alt/util/atomicTransactions to alt/util/atomic
  • Removed mixins from browser-with-addons. commit

Mixins are dead, all hail our new higher-order component overlords. Please use AltContainer instead: http://alt.js.org/docs/components/altContainer/

  • Method signature for beforeEach, afterEach, error lifecycle events have changed. commit

    Upgrade Guide

    • Previously the method signature looked like fn(actionName, data, state).
    • Now it has been simplified to fn(payload, state) where payload is an object.
    • The payload object contains keys action and data which contain the information from before.
class Store {
  constructor() {
    this.on('beforeEach', (payload, state) => {
      console.log(payload.data);
    });
  }
}

Added

@timetravel
class TodoStore { }

TodoStore.undo(3);
TodoStore.redo(1);
  • connectToStores function which also works with decorators. commit
@connectToStores
class TodoApp extends React.Component {
  static getStores() {
    return [TodoStoreStore]
  }
  static getPropsFromStores(props) {
    return TodoStore.getState()
  }
  render() {
    return (
      <div>
        {this.props.todos.map(todo => <Todo todo={todo} />}
      </div>
    )
  }
}
  • ImmutableJS support, in an addon as a decorator. commit
@immutable
class TodoStore {
  constructor() {
    this.state = Immutable.Map({})
  }
}
  • Use store references to take snapshots. commit
alt.takeSnapshot(TodoStore); // returns only TodoStore's snapshot
  • Use store references to recycle. commit
alt.recycle(TodoStore); // recycles only TodoStore
  • Simple decorators for creating stores and actions. commit
import { createStore } from 'alt/utils/decorators'

@createStore(alt)
export default class TodoStore {
  constructor() {
  }
}
  • Apply transforms at the app level to modify each store before it is created. commit
alt.stateTransforms.push(Store => {
  // make every store atomic
  return atomic(alt)(Store)
})
  • Add specific configuration to your stores, like how getState and setState behave. commit
class TodoStore {
  static config = {
    getState(state) {
      // adds a new todo every time you getState
      return states.todos.push({ 'Another todo!' });
    }
  }
}
  • Create your actions inside the constructor by using instance properties. commit
class FooActions {
  constructor() {
    this.myAction = function (x) {
      this.dispatch(x);
    };
  }
}
  • All actions created are now available in alt.actions. commit

  • inject prop to AltContainer. commit

// inject lets you inject arbitrary props to your children

<AltContainer inject={{ foo: 7, bar: 'hello' }}>
  <div />
</AltContainer>

// div gets prop foo=7 and bar='hello'
  • component prop to AltContainer. commit

  • alt has a prepare method which prepares a payload for bootstrapping. commit

// rather than rendering its children you can now pass in a component

<AltContainer component={MyComponent} />

// equivalent to

<AltContainer>
  <MyComponent />
</AltContainer>
  • Allow customizing where you assign your state as a key. commit
// if you yearn for a react-like API you can now has

const alt = new Alt({ stateKey: 'state' });

class Store {
  constructor() {
    this.state = {
      stateGoesHere: 1,
      yay: 2
    };

    this.nowItsPrivate = true;
  }
}
// Customize the way getState and setState behave at the app level.

const alt = new Alt({
  getState(state) {
    // add fuzzlewuzzle to every state
    state.fuzzlewuzzle = true;
    return state;
  },

  setState(existingState, newState) {
    // forget existingState, in with the new out with the old
    return newState;
  }
});
  • Added maxEvents parameter to DispatcherRecorder. This allows you to specify how many events you wish to record. commit

Fixes

  • Performance improvement when creating a really large number of actions. commit
  • finalStore is cached per alt instance so it only returns one. commit
  • Override a store's name using displayName. commit
  • Fix context for nested components. commit
  • Fix AltContainer and AltNativeContainer's rendering. commit
  • setState now emits a change immediately if the dispatcher is not dispatching. commit

Changes

  • Internals were refactored. commit
  • Babel was upgraded to babel5. commit
  • Action symbols are now prefixed with alt/. commit
goatslacker
published 0.16.0 •

goatslacker
published 0.15.6 •

Changelog

Source

0.15.6

Added

  • Adding unlisten lifecycle method. commit
  • AltContainer now takes in store listeners for functions. commit
  • listen now returns the unlisten function. commit
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc